You can run your model using
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.
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:
In the Configuration Parameters dialog box, select Hardware Implementation.
From the Hardware board drop-down list, select
RTX in Operating system parameter.
If you have selected
Baremetal as the operating system,
select a scheduler option from the Base rate trigger drop-down
Select an option from Build action drop-down list for the build process during code generation.
For more information see, Getting Started with Embedded Coder Support Package for STMicroelectronics Discovery Boards.