This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello everyone,
I am trying to measure the time elapsed to execute a certain code segment. My development environment MATLAB/SIMULINK with necessary toolboxes. I know this can achieved by configuring one of the CPU timers and reading their values as needed. The problem is that I do not know how to do it in MATLAB/SIMULINK. I am guessing one would have to write custom code blocks and make them extern C code. I would be glad if someone could point out the related resources (an example or a literature) in this topic.
Thanks,
Ganesh
Hi Santosh
Thank you for your reply
I went through the thread and tried implementing it. However, I am getting only 0 as the output. I tried debugging but couldn't find where I could have made mistake. One thing that I noticed was the function "startCpuTimer2()" had no function definition. I went ahead and set the TSS bit to 0 to start the timer. Still I couldn't get any output. I would glad if you could help me resolve the issue.
Thanks,
Ganesh
Ganesh,
I have contacted MathWorks team to help on this. We expect response by tomorrow.
Hi Ganesh,
I guess the Memory Copy block to read the timer value in your model might not be configured properly.
The "Source code symbol" parameter under Source tab needs to specify the address of the variable in which the difference of the timer values is stored (for example, &dct1).
Also, under Destination tab, the Sample time must be set to a value other than 'inf' (say 1.0) in order to read and display the timer difference value every step time.
Setting it to 'inf' will read the value only once during model initialization.
Best Regards,
Ram Alla.
Hi Ram,
Thanks. I realized I hadn't specified the address of the variable correctly.