This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Asynchronous Event Support

Adding an Asynchronous Event

The Simulink® Real-Time™ software includes support for asynchronous events in response to an interrupt from I/O boards. In response to these interrupts, the CPU can suspend normal execution and jump to another section of code called an Interrupt Service routine (ISR).

When developing an Simulink Real-Time model, you can model an Interrupt Server Routine (ISR) by using a Function-Call Subsystem. Also, add an IRQ Source block connected to the Function-Call Subsystem block. This subsystem is then executed when an interrupt occurs and the CPU is ready to accept it.

After you install an I/O board with interrupt support into your target computer, you can add Simulink Real-Time asynchronous blocks to your Simulink model.

  1. In the MATLAB® Command Window, type


    The Simulink Real-Time Library opens.

  2. Double-click the Asynchronous Event group block.

    The Library: slrtlib/Asynchronous Event window opens.

  3. Drag the Simulink Real-Time IRQ block into your Simulink model and connect the output to this block to the input of a Function-Call Subsystem. For more information on Function-Call subsystems, see the Simulink and Simulink Coder™ documentation.

    In the setup shown above, the CPU executes the contents of the Function Call-Subsystem whenever IRQ 5 occurs.

  4. Double-click the IRQ Source block.

    The Block Parameters: IRQ Source dialog box opens.

  5. To determine and use the IRQ that the BIOS assigned to the board, from the IRQ line number list, choose Auto (PCI only).

    Alternatively, choose one of the values 3–15 for this number. To determine the available IRQ line numbers on the target computer, use the function

  6. From the I/O board generating the interrupt drop-down list, select an interrupt board.

  7. In the PCI slot (-1: autosearch) or ISA base address field, enter the PCI slot number or enter -1 to let the Simulink Real-Time software determine the number.

  8. Click OK.

For more information about the IRQ Source block, see Async IRQ Source.

To transfer data from your ISR, add an Async Transition block or Async Read/Write block to your Simulink model. See Async Rate Transition, Async Buffer Write and Read, and Asynchronous Interrupt Examples.

If you are using a CAN field bus with interrupts, see Asynchronous Interrupt Examples.

Asynchronous Interrupt Examples

The Simulink Real-Time software provides several example models. If you installed the MATLAB software in the default location, these models are located here:


To access these models, in the MATLAB Command Window, type the name of the model. Each model contains annotations documenting its purpose, and serves as an example of how to use these blocks.

  • xpcasyncbuffer — Model using an external TTL signal to trigger and interrupt on the parallel port. Data exchange between an asynchronous task and a monotonic task using Async Buffer Read/Write blocks.

  • xpcasynctrans — Model using an external TTL signal to trigger and interrupt on the parallel port. Data exchange between an asynchronous task and a rate monotonic task using an Async Rate Transition block.

  • xpccanintpc104 — Model using interrupt driven CAN I/O communication with the CAN-AC2-104 board.

  • xpccanintpci — Model using interrupt driven CAN I/O communication with the CAN-AC2-PCI board.

Was this topic helpful?