Frequently Asked Questions

Why do the HIGH or FAST interrupts not work? (FAST is saving/restoring registers, or a non HIGH/FAST interrupt is being serviced high priority)

In the PIC® MCU, a FAST or HIGH interrupt is an interrupt that can interrupt another interrupt. This is achieved by setting the priority bit for that interrupt. For most interrupts there are three bits for an interrupt: an enable, a flag/status and a priority. Setting the priority bit for an interrupt will make that interrupt source high priority, meaning it can interrupt a low priority interrupt.

In CCS, we provide two methods of using high priority interrupts - the FAST and the HIGH method. Here's examples using the external trigger interrupt:

#int_ext FAST
High priority interrupt. Compiler DOES NOT save/restore key registers. This interrupt will interrupt any normal interrupt in progress.Only one is allowed in a program.

#int_ext HIGH
High priority interrupt. Compiler saves/restores key registers. This interrupt will interrupt any normal interrupt in progress.

However, there is one gotcha regarding high priority interrupts on a PIC®MCU: not all interrupt sources have a priority configuration bit. For example, EXT0 on a PIC18F452 does not have a priority configuration bit. If a PIC® MCU has been configured to use high priority interrupts, any interrupt that does not have a priority configuration bit is serviced as a high priority by the PIC®MCU. (Meaning, an EXT0 interrupt source will jump to the high priority interrupt vector even if you did not specify FAST or HIGH in CCS).

This gotcha will manifest itself in the CCS C Compiler in a few undesirable ways:

  • If you are using any high priority interrupts, any interrupts that you enable that do not have a priority configuration bit will be serviced by the high priority interrupt. This is true even if you do NOT specifiy the interrupt to be FAST or HIGH.

  • If you are using any high priority interrupts, and you are also trying to use an interrupt that does not have a priority configuration bit, then all high priority interrupts will be serviced with the HIGH method regardless if you specified the FAST method. That means status registers will be saved/restored by the high priority interrupt even IF you used the FAST method.

C-Aware IDE Demo
Embedded C Learners Kit
EZ App Lynx