For reliable communications, I always clear the receive buffer before transmitting a request to any perif. That way if you have some noise on the comm lines, it won't be interpreted as bad data.
For reliable communications, I always clear the receive buffer before transmitting a request to any perif. That way if you have some noise on the comm lines, it won't be interpreted as bad data.
Dave Purola,
N8NTA
EN82fn
MY Defines are now :-
DEFINE HSER_RCSTA 90H 'Set receive status and control
DEFINE HSER_TXSTA 24H 'Set transmit status and control
DEFINE HSER_BAUD 9615 'Baud Rate
DEFINE HSER_CLROERR 1 ' Clear Buffer
Andy,
You can always just use a "HSERIN" bogus statement to throw away anything in the buffer before you execute your regular "HSERIN" statements.
Since the EUSART has a 2 byte buffer you may need to do two of the bogus "HSERIN" statements with timeouts just to make sure you don't get stuck waiting.
Regards,
TABSoft
Hi
Thanks for reply ...
Will try tomorrow and post what happens ...
Thank you for advice
Andy
Hi,
Just keep in mind that if there is no garbage data in the RX buffer then the bogus statement will throw away the real data when it comes so if you go down that route make sure you specify a very low timeout value for the initial bogus statement.You can always just use a "HSERIN" bogus statement to throw away anything in the buffer before you execute your regular "HSERIN" statements.
Here's another way to flush the buffer:
/Henrik.Code:RCIF VAR PIR1.3 ' Alias to the RX Interrupt flag for USART 1 on an 18F25k22 Dummy VAR BYTE WHILE RCIF Dummy = RCREG1 WEND
Bookmarks