Main Content

Timer-Driven Task

Timer-driven tasks execute at a periodic rate equal to an integer multiple of the Simulink® model fundamental sample time.

To create a timer-driven task, connect the task port of a Task Manager block to a periodic event port on a Model block. Each rate in a Model block generates a unique model periodic event port with the time step for the rate shown on the block icon. In the Model block dialog mask, use the Schedule rates parameter to enable model periodic event ports.

Note

A timer-driven task requires a lower priority than an event-driven task.

Create a Simulink Model with an Timer Driven Task

This example shows how to create and configure a Simulink model to use the timer driven task feature of the SoC Blockset.

Create a Software Reference Model

This section shows how to create a reference model of the software for an SoC application model. The software contains one timer driven task subsystem.

  1. Create a new blank model.

  2. In the Simulink editor, add a Subsystem block to the model. Add a Sine block and connect it to the Subsystem block. Connect the output of the Subsystem block to a Terminator block.

  3. Open the subsystem block.

  4. Open the Block parameters dialog box of the Inport block, set the Sample Time to 0.1.

  5. In the Simulink editor, open the Configuration Parameters dialog box.

  6. Select the Hardware Implementation pane, set Hardware board to Xilinx Zynq UltraScale+ MPSoC ZCU102 Evaluation Kit.

  7. Save the model as soc_task_createtimerdriventask_software.slx.

The completed model should look similar to the following model.

Create the SoC Application Model

This section shows how to create the top level SoC application model that contains the software reference model developed in the previous section.

  1. Create a new blank model.

  2. In the Simulink editor, add a Model block and open the Block Parameters dialog box.

  3. Check Main > Schedule Rates and set Main > Model name to soc_task_createtimerdriventask_software.slx.

  4. In the editor, add a Task Manager block to the model.

  5. (Optional) Open the Block Parameters dialog box of the Task Manager block. By default, the task Type is Timer-driven with a Period of 0.1. On the Simulation tab, you specify the task duration for that task. For more information on setting task duration, see Task Duration.

  6. In the editor, connect the Task1 port to the D1[0.1] port of the Model block.

  7. Open the Configuration Parameters dialog box, select the Hardware Implementation pane, set Hardware board to Xilinx Zynq UltraScale+ MPSoC ZCU102 Evaluation Kit.

  8. Update the diagram, press Ctrl+D.

  9. Save the model as soc_task_createtimerdriventask_application.slx.

The completed model should look similar to the following model.

Run the Model with Timer Driven Task

In the Simulink editor, run the soc_task_createtimerdriventask_application.slx model. When the run completes, open the Simulation Data Inspector and select Task1. The Simulation Data Inspector shows that Task1 triggers each 0.1 time steps.

See Also

Related Topics