Detect and Fix Task Overruns on Texas Instruments C2000 Hardware
You can configure a Simulink® model running on the target hardware to detect and notify you when a task overrun occurs. A task overrun occurs if the target hardware is still performing one instance of a task when the next instance of that task is scheduled to begin. You can fix overruns by decreasing the frequency with which tasks are scheduled to run, or by reducing the number of tasks defined by your model.
Follow these steps to detect task overruns:
In the Modeling tab on the Simulink model toolstrip, click Model Settings. In the Configuration Parameters dialog box, select Hardware Implementation > Target Hardware Resources > Overrun detection.
Select the Enable overrun detection option.
Use the Digital output pin to set on overrun parameter to specify the GPIO pin number of a digital output.
Set the GPIO mode to
Set
,Clear
orToggle
.If you set the Additional notification option parameter to
Trigger Interrupt
orCall user-defined function
, Simulink triggers the ISR associated with the specified PIE and CPU numbers.Click OK.
When a task overrun occurs:
The state of the digital output pin specified in the Digital output to set on overrun parameter changes from low (0 Volts) to high (3.3 Volts).
If Additional notification is selected as Trigger Interrupt then ISR with mentioned PIE and CPU number will be triggered.
Note
Set the priority value of the interrupt to less than 40 (default base rate priority) to ensure that the interrupt triggers.
If Additional notification is selected as Call user-defined function then C function will be called on overrun.
The model continues running, but the effective sample time is longer than specified.
To fix an overrun, reduce the processing burden of the model by applying one or more these solutions:
Using profiling to measure the execution time of each task and analyze the overrunning task.
Increase the sample times for the model. For example, increase the values of the Sample time parameters in all the data source blocks.
Simplify the model.
If you are using external mode, and the preceding solutions do not fix the task overrun, consider disabling external mode. External mode adds a lightweight server to the model running on the target hardware. This server increases the processing burden upon the target hardware, which can contribute to a task overrun. The profiling logic also adds to the overhead and can contribute to a task overrun.
See Also
Overrun detection | Configuring Additional Options for Code Generation