Hardware Interrupt
Trigger downstream function-call subsystems from interrupt service routine for Arduino AVR core
Since R2024a
Add-On Required: This feature requires the Simulink Support Package for Arduino Hardware add-on.
Libraries:
Simulink Support Package for Arduino Hardware /
Advanced /
AVR
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 the event ports of the block.
This block generates code only for the ISR 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 ADC conversion complete interrupt parameter.
In the Hardware Interrupt block, set these parameters:
Interrupt group to
Analog to digital converter (ADC)
Interrupt name to
ADC
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 either
Timer 0
,Timer 1
,Timer 2
,Timer 2
,Timer 3
,Timer 4
, orTimer 5
.Interrupt name to the available ISRs depend on the Interrupt group.
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® Uno
Arduino Mega 2560
Arduino Mega ADK
Arduino Leonardo
Arduino Micro
Ports
Output
Parameters
Version History
Introduced in R2024a