This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Set Up Scheduling Options

You can run your model using Baremetal or CMSIS-RTOS RTX operating system that you can select in Configuration Parameters > Coder Target > Operating system options > Operating system.

By default, the Baremetal runs the scheduler in multitasking, multirate mode. You can also choose single tasking for your model in the Solver pane. With Baremetal, you can run the generated code with the scheduler selected in the Configuration Parameters > Coder Target > Scheduler options > Base rate trigger for your model. The model blocks run in a periodical fashion clocked by the periodical interrupt whose period is set to the base sample time of the model. Use Baremetal for faster context switching, more efficient use of stack memory, and to gain visibility of the scheduler code.

An example of how the code is generated for the STM32F4-Discovery board that uses SysTick Scheduler as the Base rate trigger follows:

The SysTick timer is configured so that the base rate sample time of the model corresponds to the interrupt rate. The timer period and prescaler are calculated and set up to produce the desired rate.

The minimum achievable base rate sample time depends on the model complexity. The maximum value depends on the maximum timer period value (224–1 for SysTick) and the CPU clock speed. The CPU clock speed is 168 MHz for the STMicroelectronics Discovery board. If the blocks in the model inherit their sample time value, and a sample time is not explicitly defined, the default value is 0.2 s.

With CMSIS-RTOS RTX, you can schedule to run your code based on the rates present in your model. The RTOS provides a standard programming interface with functions that support thread management and time management. Use RTOS to integrate with legacy code that depends on the RTOS, such as device driver code.

When using RTOS, make sure to set your model base rate to a value greater than or equal to 1 ms. The RTOS supports a maximum of seven thread priorities, in which the highest six thread priorities are used for scheduling model rates and the idle thread priority is reserved for the external mode simulation. When using the RTOS, the value that you specify in Configuration Parameters > Optimization > Signals and Parameters > Maximum stack size drop-down list applies to each thread. However, the specified stack size may not be fully utilized in some of the threads.

To set the scheduling options for your model to run on the target hardware:

  1. In the Configuration Parameters dialog box, select Hardware Implementation.

  2. From the Hardware board drop-down list, select STM32F4–Discovery.

  3. Select Baremetal or CMSIS-RTOS RTX in Operating system parameter.

  4. If you have selected Baremetal as the operating system, select a scheduler option from the Base rate trigger drop-down list.

  5. Select an option from Build action drop-down list for the build process during code generation.

  6. Click Apply.

For more information see, Getting Started with Embedded Coder Support Package for STMicroelectronics Discovery Boards.