Activate the Scheduling Feature
The generated code includes scheduling code that executes application code based on sample times specified in the model. An ARM Cortex-A processor typically uses an operating system for scheduling application code.
Create and add a new
OperatingSystem
object,os
, to yourTarget
object,tgt
, by callingaddNewOperatingSystem
with the name of the scheduler, for example,'Linux'
.os = addNewOperatingSystem(tgt,'Linux');
Do not delete the
OperatingSystem
object from the MATLAB® workspace before you save the target.Confirm that the operating system
'Linux'
is added to your target.show(tgt);
My ARM Cortex A Board Display Name My ARM Cortex A Board My New Deployer 1 Linux 0
The operating system
'Linux'
is added to the target. However, the0
indicates that the operating system is not used for the hardware'My ARM Cortex A Board'
Map the
OperatingSystem
object to theHardware
object,hw
.map(tgt,hw,os);
Confirm that the operating system
'Linux'
is used for the hardware'My ARM Cortex A Board'
show(tgt);
My ARM Cortex A Board Display Name My ARM Cortex A Board My New Deployer 1 Linux 1
The
1
indicates that the operating system'Linux'
is used for the hardware'My ARM Cortex A Board'
.Save the information that describes a target to its framework.
saveTarget(tgt);
Test that the scheduler works correctly.
testTarget(tgt,'scheduler')
Upon completion of the test, a summary result is displayed. If the test
PASSED
, then you can proceed with adding the next feature. Otherwise, if the test eitherFAILED
or isINCOMPLETE
, a link to the test diagnostic logs is shown below the test summary.
Confirm the Model Builds Successfully
Create a blank Simulink® model named
test
.In the model, select Modeling > Model Settings.
In the Configuration Parameters dialog box, on the Solver pane.
From the Type list, select
Fixed-step
. From the Solver list, selectauto
.In the Configuration Parameters dialog box, on the Hardware Implementation pane, set Hardware board to the hardware you registered, for example,
'My ARM Cortex A Board'
.On the Solver pane, enable Treat each discrete rate as a separate task.
On the Simulation Target pane, clear Advanced parameters > Block reduction.
On the Code Generation > Interface pane, select MAT-file logging. Click OK.
Open the Simulink Library Browser and from the Sources library, add a Constant block to your model. In this block, set Sample time to
1
.Add another Constant block to the model. In this block, set Sample time to
2
and Constant value to2
.From the Sinks library, add a To Workspace block to your model. In this block, set Save format to
Array
.Add a copy of the To Workspace block to the model.
Connect the first Constant block to the original To Workspace block. Similarly, connect the second Constant block to the copy of the To Workspace block.
Build your model. After the build completes, the code runs on your hardware for 10 seconds and then stops.