Hardware Interrupt
Trigger downstream function-call subsystems from interrupt service routine for Arduino SAMD21 core
Since R2023b
Add-On Required: This feature requires the Simulink Support Package for Arduino Hardware add-on.
Libraries:
Simulink Support Package for Arduino Hardware /
Advanced /
SAMD
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 ADC peripheral on the Hardware Interrupt block:
Your Simulink model must have an Analog Input block. In the block, select the Enable end of conversion interrupt parameter.
In the Hardware Interrupt block, set these parameters:
Interrupt group to
Analog to digital converter
Interrupt name to
ADC_Handler
Events to serve to
ADC RESRDY
orADC OVERRUN
Similarly, to create an ISR for the PWM peripheral on the Hardware Interrupt block:
Your Simulink model must have a PWM block. In the block, select the Enable compare match (MCx) interrupt or Enable overflow/underflow (OVF) interrupt parameter or both the parameters.
In the Hardware Interrupt block, set these parameters:
Interrupt group to
Timer/Counter for Control Applications (TCC)
.Interrupt name to either
TCC0_Handler
,TCC1_Handler
, orTCC2_Handler
.Events to serve to
TCCx overflow
,TCCx MCx
.
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 Boards
Arduino MKR 1000
Arduino MKR ZERO
Arduino MKR Wi-Fi® 1010
Arduino Nano 33 IoT
Ports
Output
Parameters
Version History
Introduced in R2023b