Main Content

External Interrupt

Trigger the downstream function-call subsystem from an Interrupt Service Routine

Since R2021a

  • External Interrupt block

Libraries:
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32F746G-Discovery
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32F769I-Discovery
Embedded Coder Support Package for STMicroelectronics STM32 Processors / STM32L475VG-Discovery (B-L475E-IOT01A)
Simulink Coder Support Package for STMicroelectronics Nucleo Boards / Common
Simulink Support Package for Arduino Hardware / Common

Description

The External Interrupt block configures Simulink® to treat the downstream Function-Call Subsystem, connected to the output port of the block, as an Interrupt Service Routine (ISR). ISR is a section of code that the CPU triggers when the selected interrupt occurs at the selected pin of the hardware.

During simulations you can provide an input to the External Interrupt block by connecting a boolean signal from the Simulink library to the input port of the External Interrupt block. If selected Trigger type edge is detected in the boolean input, the block triggers the downstream function-call subsystem. If you do not provide an input, the block triggers the downstream function-call subsystem until the simulation continues to run. During code generation, any simulation block that is connected to the input port of the External Interrupt block is ignored and has no effect on the generated code.

Note

We recommend that you use the External Interrupt block only in the parent model in a model hierarchy. For more information, refer to Model References.

Ports

Input

expand all

During simulations you can simulate an input to the block by connecting a boolean signal from the Simulink library to the SimIRQ port. If the input provided to the block is boolean true, the block triggers the downstream function-call subsystem. If no input is provided, the block triggers the downstream function-call subsystem until the simulation continues to run. During code generation, any block that is connected to this port is ignored and has no effect on the generated code.

Dependencies

To enable this port, select the Enable simulation input.

Data Types: Boolean

Output

expand all

The IRQ port connects the downstream Function-Call Subsystem to be triggered when the selected interrupt occurs.

Parameters

expand all

Specify the digital input pin name on the hardware to be used to generate external interrupts. The pins that can be used for interrupts are different for different STMicroelectronics® hardware boards.

Click View pin map to open the STMicroelectronics Pin Mapping table.

Select one of these modes.

  • Pull-up – The selected hardware pin is set to logical high when no input is connected to the pin.

  • Pull-down – The selected hardware pin is left floating when no input is connected to the pin.

  • No pull-up or pull-down – The selected hardware pin is not set to either logical high or left floating when no input is connected to the pin.

Select a Trigger type to specify which of these transitions on the selected pin triggers the downstream function call.

Trigger typeInterrupt Trigger Condition
RisingThe digital pin value goes from low to high.
FallingThe digital pin value goes from high to low.
EitherThe digital pin value goes from either low to high or high to low.

This figure shows how the block executes the downstream function call as the pin value changes in different interrupt modes.

The parameter enables the SimIRQ input port.

Select one of these pin status.

  • false - Initial pin status is 0.

  • true - Initial pin status is 1.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2021a