USART interupts; Why use them?
Harold M Hallikainen email (remove spam text)
On Wed, 20 Oct 1999 04:56:08 -0400 Darren King <SYMPATICO.CA> darren.king
Yep, you have to poll the interrupt flags in the ISR, typically with a
bunch of BTFSC, CALL sequences. My ISR's start with a SAVECONTEXT macro,
the BTFSC, CALL's for each possible interrut (remembering the clear the
interrupt flag in the called routine).
In my typical applications (ligting control), I use interrupts on both
transmit and receive. I have a buffer in RAM holding all the DMX data I
want to transmit. Based on an interrupt, the buffer data is transmitted
continuously. Note, however, that in this case I use a timer interrupt
instead of the UART interrupt because I have to synchronize BREAK signals
with the transmitted data. I found using a timer IRQ was easier than
trying to figure out when the UART had finished transmitting the byte.
In a more typical serial transmission situation, I've used transmit
interrupts with a circular buffer in RAM. The non-interrupt code then
does not have to wait around for the UART, just dump the data into the
buffer and go on. The ISR pulls the stuff from the buffer and transmits
it. I've done similar stuff with driving LCD modules, though they do not
generate an interrupt. If you have a timer interrupt calling the ISR now
and then, then poll everything (including an LCD module status bit), you
can get a lot done in the background.
Get the Internet just the way you want it.
Free software, free e-mail, and free Internet access for a month!
Try Juno Web: dl.http://www.juno.com/dynoget/tagj.
See also: www.piclist.com/techref/io/serials.htm?key=usart
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the