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 support@ccsinfo.com

How to know the recieve buffer is full in rs232

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mkr



Joined: 08 Aug 2006
Posts: 49

View user's profile Send private message

How to know the recieve buffer is full in rs232
PostPosted: Tue Aug 29, 2006 3:43 pm     Reply with quote

I have some issues regarding the rs232 USART1 for 18F8722. How can I know that the received data is complete. For example, I have 6 bytes sending to my board. I have the int_rda enabled. I am monitoring PIR1.5 to go high once I ahve recieved all 6 bytes. I dont see it going high. Is it a latched state.

I want a clear explination.
_________________
Thanks

mkr
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Tue Aug 29, 2006 11:33 pm     Reply with quote

The int_RDA interrupt will be flagged as soon as ONE character has been received. The service routine will, then, be entered. It is up you to enter what ever code is necessary to put that character wherever you need to keep it. If you are looking for multiple bytes then you will, most likely, need to increment a variable each time a character is received and then use it to keep track of where they are stored. It is up to you to determine if all of the bytes have been received by counting how many have come in. The only thing the PIC can do is to detect that a character has been received. You need to do all of the foot work on what happens to each character.

There are boat loads of threads on this topic.

Ronald
Guest








PostPosted: Wed Aug 30, 2006 2:32 am     Reply with quote

Add some more to this.
The 8722, has a maximum of 2.9999 characters of receive storage. Two characters in the FIFO, and the receive shift register itself. As soon as the receive shift register is full, with a third character, if at least one of the earlier characters has not been retrieved from the FIFO, there will be an overrun error, and the receive component of the UART will be disabled.
To handle 6 characters, and know when six have been retrieved, you need to implement a software buffer (look at the EX_SISR example). If you add to this a test, for the buffer containing 6 characters, and set a flag when this is 'true', then your external code, can just look for this happening, and have 6 characters waiting in the software buffer for retrieval.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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