Page 1 of 1
Interupt Question
Posted: Thu Nov 12, 2020 5:19 pm
by anzacinexile
Hopefully a simple question being asked by a novice.
If a PIC is halfway through transmitting (or receiving) a RS232 string and an interrupt occurs, does the PIC respond immediately to the interrupt (and corrupts the RS232 string) or will it complete the RS232 task before responding to the interrupt?
Many thanks
Chris
Re: Interupt Question
Posted: Thu Nov 12, 2020 5:34 pm
by Bachman
The RS232 (UART) module is a dedicated module, controlled by the CPU. The CPU "tells" to the UART module to send a character and continues executing the program. The CPU can handle the interrupt during UART data transfer while the UART module is still transmitting or receiving the data. Same results with other peripherials. Here is the block diagram of a relatively simple µC, PIC12F1840:

- PIC12F1840.png (41.4 KiB) Viewed 2292 times
Edit:
Not all pheriperials shown on this picture, mistake in the datasheet.
Re: Interupt Question
Posted: Thu Nov 12, 2020 6:07 pm
by Benj
Hi Chris,
I agree with Bachman as long as the interrupt macro is fairly short lived. i.e. no delays or large amounts of code.
Unless your using a software UART and then all bet are off. Software UARTs should be last resort only and only used if/when you don't have any active interrupts.
Re: Interupt Question
Posted: Fri Nov 13, 2020 5:06 pm
by anzacinexile
Cheers guys, much appreciated
Chris