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:
Open the Code Replacement Tool. In the Command Window, enter
crtool
.Create a new code replacement table. Select File > New table.
Create a new function entry. Under Tables List, right-click the new table. Then, from the context-menu, select New entry > Function.
In the middle view, select the new unnamed function.
On the Mapping Information pane:
From the Function drop-down list, select
code_profile_read_timer
.Specify the count direction for your timer. For example, from the Count direction drop-down list, select
Up
.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.
In the Conceptual function section, from the Data type list, select
uint8
,uint16
,uint32
, oruint64
.In the Function prototype section, in the Name field, specify a replacement function name, for example,
MyTimer
.Click Apply.
To validate the function entry, click Validate entry.
On the Build Information pane, specify the required build information. See Specify build information in Define Code Replacement Library Optimizations.
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.
Assuming you save the table as
, in your subclass ofMyCrlTable
.mrtw.connectivity.Config
, add the following line:setTimer(this, MyCrlTable)
Related Examples
- Create a Target Connectivity API Implementation
- Generate Execution Time Profile
- Define Code Replacement Library Optimizations