Main Content

Create Hardware Interrupt Block for an ARM Cortex-M Based Processor using an Interrupt Description File

You can create your own interrupt block for ARM® Cortex®-M targets using the existing Hardware Interrupt block from the Embedded Coder® Support Package for ARM Cortex-M Processors library. This block supports NVIC (Nested Vectored Interrupt Controller) of ARM Cortex-M core that can handle interrupts from different peripherals such as ADC, DMA, and Watchdog.

To create an interrupt block for an ARM Cortex-M target:

  1. Install Embedded Coder Support Package for ARM Cortex-M Processors.

  2. Create an xml interrupt description file with details of the interrupt groups and the interrupts under them, based on the interrupt vector table of your ARM Cortex-M based processor. You can find an example of an interrupt xml file in the path: ARM Cortex-M support package root directory > registry > interrupts>.

    • Use the groups (IrqGroup) to bundle interrupts of the same type. This grouping allows you to limit the size of the interrupt name list. The IrqName inside one group populates the "Interrupt name" dropdown list. This name is also used in code generation and has to match the entry in your interrupt vector table. The IrqNumber corresponds to the ARM Cortex-M vector table position and has to match the mapping of the specified interrupt by the silicon vendor. Cortex-M-based processor can use up to eight priority bits.

    • Refer to your Silicon vendor specifications to specify NumberOfPriorityBits.

    • You can disable "Disable interrupt pre-emption" check box by specifying ShowPreemptionOption as this functionality may not be available on your device.

  3. Copy the ARM Cortex-M Interrupt block from the Embedded Coder Support Package for ARM Cortex-M Processors library into new library model or your processor block library.

  4. Register your xml description file along with its path using the command set_param(<hardware interrupt block>, ‘InterruptsXMLPath’, <interrupt descritpion file>) in the MATLAB® command prompt. Here, <hardware interrupt block> > corresponds to the block handle in the library (gcb can be used if the block is selected) and <interrupt xml file> corresponds to your interrupt description file with full path.

  5. To open the mask window that shows the entries of your interrupt description file, double-click the ARM Cortex-M Interrupt block. The interrupt groups, interrupt names, and the interrupt numbers specified in your interrupt description file appear in the corresponding block parameters.

  6. Save the library. You can now place the newly created hardware interrupt block and use it in your application models.

A sample xml interrupt description file with the entries mapped to the parameters on the mask window is as shown.