Page 1 of 1

RS232 Clearing Buffer???

Posted: Wed Jul 20, 2011 9:00 pm
by cobra1
Hi,

i am having a problem with the RS232, basically if i send data across to my PIC without the code actually receiving the character, it seems to sit there.
When i actually want the PIC to read the data sent to it, it reads the data that was sent to it before hand first,

Is there a way to wipe this "buffer" if thats what it is, so that it will only receive what i want it to when i want it to??

Re: RS232 CLEARING BUFFER???

Posted: Thu Jul 21, 2011 9:44 am
by Benj
Hello,

The RS232 will buffer up to two bytes of data before generating an overflow error. The error and the two data bytes can be cleared by calling the receive byte macro. You could simply call two or three dummy RS232 reads when you are ready to receive data and this should clear the buffer. You could also use the receive interrupt to ensure you always read the byte's as they come in and then store in your own software buffer if and when you wish to receive the data.