Chapter 5

Interrupt Macros

The dspic-utility.h header file defines a number of macros for manipulating the interrupt priority level (IPL) of the microcontroller, and for using the DISI instruction.

5.1  Usage

To use these macros, you can use the -I compiler option to add the dsPIC Helper Library source directory to the compiler command line, and then include the header file like so:

  #include <dspic-utility.h>

5.2  Macros

CLI()   macro

This macro raises the IPL to 7, disabling all maskable interrupts. The previous IPL is saved in a global variable for use by STI().

STI()   macro

This macro restores the IPL to the value saved by the CLI() macro.

SET_CPU_IPL_MAX()   macro

This macro raises the IPL to 7, disabling all maskable interrupts. Unlike CLI(), the current IPL value is not saved.

DISI_SET(int n)   macro

This macro emits the DISI instruction with the given count. This disables interrupts for n + 1 cycles.

DISI_MAX()   macro

This macro emits the DISI instruction to disable interrupts for the maximum number of cycles. This macro can be used with DISI_CLEAR() to disable interrupts for a reasonably short, but unknown number of instructions.

DISI_CLEAR()   macro

This macro clears the DISICNT register to re-enable interrupts after a call to DISI_MAX() or DISI_SET().