|
|
View previous topic :: View next topic |
Author |
Message |
mkr
Joined: 08 Aug 2006 Posts: 49
|
How to know the recieve buffer is full in rs232 |
Posted: Tue Aug 29, 2006 3:43 pm |
|
|
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
|
|
Posted: Tue Aug 29, 2006 11:33 pm |
|
|
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
|
|
Posted: Wed Aug 30, 2006 2:32 am |
|
|
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 |
|
|
|
|
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
|