Main Content

Specify Hardware Timer for MATLAB

For processor-in-the-loop (PIL) code execution profiling, you must create a timer object that provides details of the hardware-specific timer and associated source files. You can use the Code Replacement Tool or the code replacement library API to specify this hardware-specific timer.

To specify the timer with the Code Replacement Tool:

  1. Open the Code Replacement Tool. In the Command Window, enter crtool.

  2. Create a new code replacement table. Select File > New table.

  3. Create a new function entry. Under Tables List, right-click the new table. Then, from the context-menu, select New entry > Function.

  4. In the middle view, select the new unnamed function.

  5. On the Mapping Information pane:

    1. From the Function drop-down list, select code_profile_read_timer.

    2. Specify the count direction for your timer. For example, from the Count direction drop-down list, select Up.

    3. In the Ticks per second field, specify the number of ticks per second for your timer, for example, 1e+09.

      The default value is 0. In this case, the software reports time measurements in terms of ticks, not seconds.

    4. In the Conceptual function section, from the Data type list, select uint8, uint16, uint32, or uint64.

    5. In the Function prototype section, in the Name field, specify a replacement function name, for example, MyTimer.

    6. Click Apply.

    7. To validate the function entry, click Validate entry.

  6. On the Build Information pane, specify the required build information. See Specify build information in Define Code Replacement Library Optimizations.

  7. Save the table (Ctrl+S). When you save the table for the first time, use the Save As dialog box to specify the file name and location.

    You must save the table in a location that is on the MATLAB® search path. For example, you can save this file in the folder for your subclass of rtw.connectivity.Config.

    The software stores your timer information as a code replacement library table.

  8. Assuming you save the table as MyCrlTable.m, in your subclass of rtw.connectivity.Config, add the following line:

    setTimer(this, MyCrlTable)

Related Examples

More About