CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

#int_rda when is it called?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Thu Jun 08, 2006 7:24 am     Reply with quote

Hi

This problem is driving me nuts.

Can someone please tell me how to clear the overrun error bit (OERR) and reset the UART?

Thank you in advance.
a.
newguy



Joined: 24 Jun 2004
Posts: 1946

View user's profile Send private message

PostPosted: Thu Jun 08, 2006 8:56 am     Reply with quote

Did you see ckielstra's post at the top of the 2nd page of this thread?

Quote:
If you have the ERRORS directive in the #use RS232 line you can reset the UART overflow bit just by calling getc(). If you want do it manually you can reset the Overrun Error bit (OERR) by clearing bit CREN (and then re-activate the UART again by setting CREN again).


The pic's datasheet will tell you which SFR contains CREN, and the memory organization section of the datasheet will tell you the address of that SFR.
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Thu Jun 08, 2006 10:02 am     Reply with quote

Hi Newguy

Yes I saw the post you mention. But I am a newbie at this, so if you could post a code snippet of how to reset the actual bit that I can modify for the PIC16F873 I would appreciate it.

Thank you
a.
newguy



Joined: 24 Jun 2004
Posts: 1946

View user's profile Send private message

PostPosted: Thu Jun 08, 2006 10:36 am     Reply with quote

Okay. I'm assuming you're using the 16F873A, since I can't find a 16F873 on Microchip's website.

First: go to chapter 10 of the datasheet, specifically page 114 of 234. This page lists what the various bits within the receive status and control register RCSTA do.

You'll find a description of bit 4, CREN (continuous receive enable bit) and bit 1, OERR (overrun error bit). Note what it says about clearing an overrun error - that it can be cleared by clearing CREN.

Now we just have to find where RCSTA is - we need its address. You have to go to chapter 2 of the datasheet (memory organization) to find this information. Specifically, you'll need section 2.2.2 special function registers, found on page 21 of 234.

You'll find that RCSTA is located at address 0x18 within the PIC's memory.

In your program you would do this (near the top of the program):

Code:
#bit overrun_error = 0x18.1
#bit cr_enable = 0x18.4


Somewhere in you code you would test for the overrun error. If that bit is set, you need to clear CREN, then re-enable CREN. Like so:

Code:
if (overrun_error) {
   cr_enable = 0;
   cr_enable = 1;
}
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Thu Jun 08, 2006 10:47 am     Reply with quote

Hi Newguy

Thank you! That is exactly what I need.
I will implement your code snippets tomorrow- I hope they will clear up my problem.

I appreciate your help
a.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group