Main Content

External Interrupt

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

  • 库:
  • Simulink Coder Support Package for STMicroelectronics Nucleo Boards/ Common

    Embedded Coder Support Package for STMicroelectronics Discovery Boards/ STM32F746G-Discovery

    Embedded Coder Support Package for STMicroelectronics Discovery Boards/ STM32F769I-Discovery

    Embedded Coder Support Package for STMicroelectronics Discovery Boards/ STM32L475-Discovery (B-L475E-IOT01A)

  • External Interrupt block

Description

TheExternal Interruptblock configures Simulink®to treat the downstreamFunction-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 selectedTrigger typeedge 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 theExternal Interruptblock only in the parent model in a model hierarchy. For more information, refer toModel 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 theSimIRQport. 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 theEnable simulation input.

Data Types:Boolean

Output

expand all

TheIRQport connects the downstreamFunction-Call Subsystemto 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.

ClickView pin mapto 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 aTrigger typeto specify which of these transitions on the selected pin triggers the downstream function call.

Trigger type Interrupt Trigger Condition
Rising The digital pin value goes from low to high.
Falling The digital pin value goes from high to low.
Either The 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 theSimIRQinput port.

Select one of these pin status.

  • false- Initial pin status is0.

  • true- Initial pin status is1.

版本历史

Introduced in R2021a