Interupt Question

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
anzacinexile
Posts: 55
Joined: Tue Apr 01, 2014 9:10 am
Has thanked: 16 times
Been thanked: 18 times
Contact:

Interupt Question

Post 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

User avatar
Bachman
Posts: 116
Joined: Sun Sep 07, 2014 11:37 am
Location: Hungary
Has thanked: 9 times
Been thanked: 53 times
Contact:

Re: Interupt Question

Post 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
PIC12F1840.png (41.4 KiB) Viewed 1868 times
Edit:
Not all pheriperials shown on this picture, mistake in the datasheet.

User avatar
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

Post 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.

anzacinexile
Posts: 55
Joined: Tue Apr 01, 2014 9:10 am
Has thanked: 16 times
Been thanked: 18 times
Contact:

Re: Interupt Question

Post by anzacinexile »

Cheers guys, much appreciated
Chris

Post Reply