Real-Time Workshop Embedded Coder    

Stand-Alone Program Execution

By default, the Real-Time Workshop Embedded Coder generates self-sufficient programs that do not require an external real-time executive or operating system. We refer to such programs as stand-alone programs. A stand-alone program requires some minimal modification to be adapted to the target hardware; these modifications are described in the following sections. The stand-alone program architecture supports execution of models with either single or multiple sample rates.

To generate a stand-alone program:

  1. In the ERT code generation options (3) category of the Real-Time Workshop tab of the Simulation Parameters dialog box, select the Generate an example main program option (this option is on by default).
  2. When Generate an example main program is selected, the Target operating system pop-up menu is enabled. Select BareBoardExample from this menu (this option is the default selection).

The core of a stand-alone program is the main loop. On each iteration, the main loop executes a background or null task and checks for a termination condition.

The main loop is periodically interrupted by a timer. The Real-Time Workshop function rt_OneStep is either installed as a timer interrupt service routine (ISR), or called from a timer ISR at each clock step.

The execution driver, rt_OneStep, sequences calls to the model_step function. The operation of rt_OneStep differs depending on whether the generating model is single-rate or multi-rate. In a single-rate model, rt_OneStep simply calls the model_step function. In a multi-rate model, rt_OneStep prioritizes and schedules execution of blocks according to the rates at which they run.

If your model includes device driver blocks, the model_step function will incorporate your inlined driver code to perform I/O functions such as reading inputs from an analog-digital converter (ADC) or writing computed outputs to a digital-analog converter (DAC).


  Program Execution Main Program