PDA

View Full Version : realise second RX-interrupt input



mischl
- 3rd February 2006, 11:03
hello all

i have an existing controller based on a 16F876A where RC7 as serial input interrupt is allready used.

now as an extension i need a second one... so i send a serial command, go back to do some work and when the answer is coming in on RX2 i should catch them. this command are about 8 chars. i don't know how long it takes until this will receive.

how could i realise them, beside to use a second PIC as coprozessor... RB4 is allready free so i could include them in the RB4-7 INTCON interrupt? i don't need the string immeadetly so if possible i could buffer them for a moment anywhere...

thanks for a hint, cheers

mister_e
- 3rd February 2006, 20:59
mmm, maybe it could work, maybe not. Depending what else the PIC do.

Is the other Serial Pin use Interupt? If not, i'll suggest to swap them. Now you'll use the internal USART Buffer and avoid some missing character.

Charles Linquis
- 4th February 2006, 03:42
It all depends on what you expect it to do. Without two UARTs it would be very difficult to receive from both ports at the same time. If it is basically one or the other, that makes the job a lot easier. In that case, you can watch for an interrupt on RB4 and jump to a SERIN2 routine (or its equivalent in assembly). You will have to turn off the UARTs interrupt while in that routine, since grabbing a character from the UART's receive buffer would screw up the timing of SERIN. If you checksum your data streams and allow for retries, this should work quite well.

I suppose you COULD measure the RB4 interrupts against a timer and decode the data stream. Difficult, but doable.