Page 1 of 1

RS232 Correct way of reading data from usart

Posted: Fri Nov 16, 2012 12:21 pm
by Tom Stefanou
Hello again guys....
I am reading data from the serial port and display them to an lcd module.
What is the proper way of reading everything from the serial port buffer?
I have searched the forum and only thing i could find was a topic from flowcode 3 where BenJ had updated the ecxample of rs232 to use an interrrupt.
To be honest i could not find that implemented in flowcode 3 or 5 examples.
So i know i am missing a lot of characters compared to the ones i should receive.
How am i supposed to do the reading from the serial port?
Thank you for your time!

Re: RS232 Correct way of reading data from usart

Posted: Fri Nov 16, 2012 12:54 pm
by Enamul
If you use RXINT, every time receive any character in the buffer interrupt will trigger and you can read that character. PIC can easily be involved in doing other stuffs. That's is much reliable than just wait and read if PIC is doing something else in the loop as well. I can post example code if you want for RXINT. BTW, which PIC you are using..bcz there are some problem in RXINT in couple of PIC and Ben posted a fix for that but I don't think you have noticed that.

Re: RS232 Correct way of reading data from usart

Posted: Sat Nov 17, 2012 1:09 pm
by Tom Stefanou
Hey Enamul,
I am using 16F877.
Yes an example would be very good i think.
Actually i want when i receive from serial the
"Would you like to activate duplex? [yes/no] :"
to light a led.
But i always am able to read some of it...