Main Content

Async Interrupt

Generate Versa Module Eurocard (VME) interrupt service routines (ISRs) that execute downstream subsystems or Task Sync blocks

  • Library:
  • Simulink Coder / Asynchronous / Interrupt Templates

  • Async Interrupt block

Description

For each specified VME interrupt level in the example RTOS (VxWorks®), the Async Interrupt block generates an interrupt service routine (ISR) that calls one of the following:

  • A function call subsystem

  • A Task Sync block

  • A Stateflow® chart configured for a function call input event

Note

You can use the blocks in the vxlib1 library (Async Interrupt and Task Sync) for simulation and code generation. These blocks provide starting point examples to help you develop custom blocks for your target environment.

Assumptions and Limitations

  • The block supports VME interrupts 1 through 7.

  • The block uses these RTOS (VxWorks) system calls:

    sysIntEnable
    sysIntDisable
    intConnect
    intLock
    intUnlock
    tickGet

Performance Considerations

Execution of large subsystems at interrupt level can have a significant impact on interrupt response time for interrupts of equal and lower priority in the system. Usually, it is best to keep ISRs as short as possible. Connect only function-call subsystems that contain a few blocks to an Async Interrupt block.

A better solution for large subsystems is using the Task Sync block to synchronize the execution of the function-call subsystem to an RTOS task. Place the Task Sync block between the Async Interrupt block and the function-call subsystem. The Async Interrupt block then uses the Task Sync block as the ISR. The ISR releases a synchronization semaphore (performs a semGive) to the task, and returns immediately from interrupt level. The example RTOS (VxWorks) then schedules and runs the task. See the description of the Task Sync block.

Ports

Input

expand all

A simulated interrupt source.

Output Arguments

expand all

Control signal for a:

  • Function-call subsystem

  • Task Sync block

  • Stateflow chart configured for a function call input event

Parameters

expand all

An array of VME interrupt numbers for the interrupts to be installed. The valid range is 1..7.

The width of the Async Interrupt block output signal corresponds to the number of VME interrupt numbers specified.

Note

A model can contain more than one Async Interrupt block. However, if you use more than one Async Interrupt block, do not duplicate the VME interrupt numbers specified in each block.

An array of unique interrupt vector offset numbers corresponding to the VME interrupt numbers entered for parameter VME interrupt number(s). The Stateflow software passes the offsets to the RTOS (VxWorks) call intConnect(INUM_TO_IVEC(offset),...).

The Simulink® priority of downstream blocks. Each output of the Async Interrupt block drives a downstream block (for example, a function-call subsystem). Specify an array of priorities corresponding to the VME interrupt numbers that you specify for parameter VME interrupt number(s).

Parameter Simulink task priority values are required to generate a rate transition code (see Rate Transitions and Asynchronous Blocks). Simulink task priority values are also required to maintain absolute time integrity when the asynchronous task must obtain real time from its base rate or its caller. The assigned priorities typically are higher than the priorities assigned to periodic tasks.

Note

The Simulink software does not simulate asynchronous task behavior. The task priority of an asynchronous task is for code generation purposes only and is not honored during simulation.

Set this option to 1 if an output signal of the Async Interrupt block drives a Task Sync block.

Higher priority interrupts can preempt lower priority interrupts in the example RTOS (VxWorks). To lock out interrupts during the execution of an ISR, set the pre-emption flag to 0. This setting causes generation of intLock() and intUnlock() calls at the beginning and end of the ISR code. Use interrupt locking carefully, as it increases the interrupt response time of the system for interrupts at the intLockLevelSet() level and below. Specify an array of flags corresponding to the VME interrupt numbers entered for parameter VME interrupt number(s).

Note

The number of elements in the arrays specifying parameters VME interrupt vector offset(s) and Simulink task priority must match the number of elements in the array specified for parameter VME interrupt number(s).

If selected, the ISR generated by the Async Interrupt block manages its own timer by reading absolute time from the hardware timer. Specify the size of the hardware timer with parameter Timer size.

The resolution of the ISRs timer. ISRs generated by the Async Interrupt block maintain their own absolute time counters. By default, these timers obtain their values from the RTOS (VxWorks) kernel by using the tickGet call. Parameter Timer resolution determines the resolution of these counters. The default resolution is 1/60 second. The tickGet resolution for your board support package (BSP) can be different. Determine the tickGet resolution for your BSP and enter it for parameter Timer resolution.

If you are targeting an RTOS other than the example RTOS (VxWorks), replace the tickGet call with an equivalent call to the target RTOS. Or, generate code to read the timer register on the target hardware. For more information, see Timers in Asynchronous Tasks and Async Interrupt Block Implementation.

The number of bits to store the clock tick for a hardware timer. The ISR generated by the Async Interrupt block uses the timer size when you select parameter Manage own timer. The size can be 32bits (the default), 16bits, 8bits, or auto. If you select auto, the code generator determines the timer size based on the settings of parameteres Application lifespan (days) and Timer resolution.

By default, timer values are stored as 32-bit integers. When parameter Timer size is set to auto, you can indirectly control the word size of the counters by setting parameter Application lifespan (days). If you set Application lifespan (days) to a value that is too large for the code generator to handle as a 32-bit integer of the specified resolution, the code generator uses a second 32-bit integer to address overflows.

For more information, see Control Memory Allocation for Time Counters. See also Timers in Asynchronous Tasks.

If selected, the Simulink software adds an input port to the Async Interrupt block. This port is for simulation only. Connect one or more simulated interrupt sources to the simulation input.

Note

Before generating code, consider removing blocks that drive the simulation input to prevent the blocks from contributing to the generated code. Alternatively, you can use the Environment Controller block, as explained in Dual-Model Approach: Code Generation. If you use the Environment Controller block, the sample times of driving blocks contribute to the sample times supported in the generated code.

Introduced in R2006a