What's the best way to loop while waiting for a character
Posted: Mon Mar 14, 2005 8:48 pm
I'm working with a 16F873, using the PCWH compiler. I can transmit just fine at 1200 baud using "printf's", but when I try to read, my buffers are just filled with zeros. I've got a loop that spins in 21us increments while waiting for "kbhit()", but once that happens my program just gets a bunch of zeros in the buffer that I've set up.
1) Can I use something other than "kbhit()" to check for a character in the USART buffer, or is "kbhit()" looking for a bit flag somewhere?
2) Does anyone have an code example of the use of the serial interrupt (#INT_RDA)?
3) Which bit flags a received character in the USART receive register?
Thanks y'all.....
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Mon Mar 14, 2005 8:59 pm
Use an interrupt-driven receive fifo. See the CCS example file,
EX_SISR.C for sample code.
Also, tell us if you're using the hardware UART or a software UART.
(The hardware UART will use pins C6 and C7).
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