Main Content

Hardware Interrupt

Trigger downstream function-call subsystems from interrupt service routine for Teensy 4.0 and 4.1 Arduino compatible boards

Since R2024b

Add-On Required: This feature requires the Simulink Support Package for Arduino Hardware add-on.

  • Arduino Teensy4 Library Hardware Interrupt Block Icon

Libraries:
Simulink Support Package for Arduino Hardware / Advanced / TEENSY4

Description

Use the Hardware Interrupt block to create an interrupt service routine (ISR) automatically in the generated code of your Simulink® model for the selected interrupts. The ISR executes the downstream function-call subsystem associated with event ports of the block.

The function call subsystem associated with the event output port run at the same priority as the ISR.

Using this block, you can:

  • Create an ISR on the Arduino® board.

  • Set priority for an ISR.

  • Enable or disable interrupt preemption.

This block generates code only for the ISR and events that you select or specify. To change the configuration, enable the interrupt, and specify triggering options, use the settings of the selected peripherals. For example, to create an ISR for the CAN communication peripheral on the Hardware Interrupt block, your Simulink model must have an On-board CAN Receive or On-board CAN Transmit block.

Note

The Hardware Interrupt block supports C/C++ code generation. This feature allows you to generate C and C++ code using Embedded Coder®.

Supported Arduino Board

Arduino compatible Teensy 4.0 and 4.1

Ports

Output

expand all

The block outputs a function call. The number of function call outputs depends on the number of events you select to serve in an ISR. For example, if you select CAN rx and Custom event in the Events to serve section, the block enables CAN rx and Custom event output ports.

Parameters

expand all

This parameter lists all the available ISRs for a particular type of peripheral in an Arduino board. The values available in the Interrupt name parameter change depending on the interrupt group you select in this parameter.

The interrupt name specifies the ISR for the Hardware Interrupt block. This parameter corresponds to the specific entry in the interrupt vector table of the Arduino board. The available ISRs depend on the Interrupt group.

Dependencies

  • To enable the CAN1_Handler, set Interrupt group to Controller area network (CAN1).

  • To enable the CAN2_Handler, set Interrupt group to Controller area network (CAN2).

  • To enable the CAN3_Handler, set Interrupt group to Controller area network (CAN3).

This read-only parameter indicates the position of the ISR in the interrupt vector table of the Arduino board.

Select events or custom events and their respective execution order from the Events to serve group to service events for the Interrupt name that you select. You can select custom events to execute along with the other events. You can also change the execution order of the events.

The value you specify in this parameter sets the priority of the downstream function-call subsystem. The task priority in Simulink for the ISR is relative to the priority of the base rate that you set in the Simulink model.

Note

The default priority of the base rate in the Simulink model is 40, with a lower priority value indicating a higher priority. To achieve this, in the Configuration Parameters dialog box, select Higher priority value indicates higher task priority in the Solver pane.

Select this parameter to block all other interrupts while executing the current ISR(s).

Select this option to clear all the interrupt status flags after servicing each event.

Version History

Introduced in R2024b