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
Interupt Question
Moderator: Benj
-
- Posts: 55
- Joined: Tue Apr 01, 2014 9:10 am
- Has thanked: 16 times
- Been thanked: 18 times
- Bachman
- Posts: 116
- Joined: Sun Sep 07, 2014 11:37 am
- Location: Hungary
- Has thanked: 9 times
- Been thanked: 53 times
Re: Interupt Question
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:
Edit:
Not all pheriperials shown on this picture, mistake in the datasheet.
Edit:
Not all pheriperials shown on this picture, mistake in the datasheet.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Interupt Question
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 55
- Joined: Tue Apr 01, 2014 9:10 am
- Has thanked: 16 times
- Been thanked: 18 times