On Wed, 20 Oct 1999 04:56:08 -0400 Darren King writes: > I've been programming the PIC16F877 using Pic C. My question is > about the > interupts. With the Pic16F877 there is just one interupt vector > right? So > when ANY interupt happens it goes to the same procedure. In order > for this > to be usefull do I set up a "If this Interupt Flag is True then > this" kind > of thing or what? And as for the USART interupts. I can understand > using > the Recieve Interupt as that would allow you to buffer bytes and > then read > them when you get the time, but why would you need a send Interupt? > > 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. Harold ___________________________________________________________________ Get the Internet just the way you want it. Free software, free e-mail, and free Internet access for a month! Try Juno Web: http://dl.www.juno.com/dynoget/tagj.