Main Content

Asynchronous Events

Asynchronous Support

Normally, you time models from which you plan to generate code from a periodic interrupt source (for example, a hardware timer). Blocks in a periodically clocked single-rate model run at a timer interrupt rate (the base rate of the model). Blocks in a periodically clocked multirate model run at the fixed-step size (fundamental sample time) or at multiples of that rate.

Many systems must also support execution of blocks in response to events that are asynchronous with respect to the periodic timing source of the system. For example, a peripheral device might signal completion of an input operation by generating an interrupt. The system must service such interrupts, for example, by acquiring data from the interrupting device.

You can use blocks to model and generate code for asynchronous event handling, including servicing of hardware-generated interrupts, maintenance of timers, asynchronous read and write operations, and spawning of asynchronous tasks under a real-time operating system (RTOS). Although the blocks target an example RTOS, the content provides source code analysis and other information you can use to develop blocks that support asynchronous event handling for an alternative target RTOS.

Block Libraries for Calls to an Real-Time Operating System

To implement asynchronous support for a real-time operating system (RTOS) in a model, use blocks in the vxlib1 or Interrupt Templates block library. Both libraries include blocks Async Interrupt and Task Sync. Use the Async Interrupt block to generate interrupt-level code. Use the Task Sync block to spawn an RTOS task that calls a function call subsystem.

Block library vxlib1 also includes blocks Protected RT and Unprotected RT, which are versions of the Rate Transition block that are preconfigured for ensuring data integrity during data transfers or ensuring deterministic data transfers.

Blocks in the two libraries serve as examples that you can use as is or, with modification, to support a specific RTOS. Blocks in the vxlib1 library are configured for interacting with the VxWorks® RTOS.

To open the vxlib1 block library, enter vxlib1 at the MATLAB® command prompt.

1

More Information on Implementing Asynchronous Support

GoalRelated Information
Generate an interrupt service routine (ISR).Generate Interrupt Service Routines
Customize the Async Interrupt and Task Sync blocks for implementing asynchronous support for an RTOS.Create a Customized Asynchronous Library
Use the preconfigured Rate Transition blocks in an asynchronous context.Rate Transitions and Asynchronous Blocks
Handle rate transitions for multitasking rate-based models.Time-Based Scheduling and Code Generation
Specify an asynchronous function-call input to a referenced model.Convert Asynchronous Subsystem to a Referenced Model
Understand system calls to the VxWorks RTOS.VxWorks system documentation on the Wind River® website

Related Topics


1 VxWorks is a registered trademark of Wind River Systems, Inc.