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.

  1. Create and add a new OperatingSystem object, os, to your Target object, tgt, by calling addNewOperatingSystem 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.

  2. 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, the 0 indicates that the operating system is not used for the hardware 'My ARM Cortex A Board'

  3. Map the OperatingSystem object to the Hardware object, hw.

    map(tgt,hw,os);
  4. 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'.

  5. Save the information that describes a target to its framework.

    saveTarget(tgt);
  6. 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 either FAILED or is INCOMPLETE, a link to the test diagnostic logs is shown below the test summary.

Confirm the Model Builds Successfully

  1. Create a blank Simulink® model named test.

  2. In the model, select Simulation > Model Configuration Parameters.

  3. In the Configuration Parameters dialog box, on the Solver pane.

  4. From the Type list, select Fixed-step. From the Solver list, select auto.

  5. 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'.

  6. On the Solver pane, set Tasking mode for periodic sample times to Auto.

  7. On the Optimization pane, clear Block reduction.

  8. On the Code Generation > Interface pane, select MAT-file logging. Click OK.

  9. 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.

  10. Add another Constant block to the model. In this block, set Sample time to 2 and Constant value to 2.

  11. From the Sinks library, add a To Workspace block to your model. In this block, set Save format to Array.

  12. Add a copy of the To Workspace block to the model.

  13. 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.

  14. Build your model. After the build completes, the code runs on your hardware for 10 seconds and then stops.