Hello @stefancinipeanu
How can I use MBDT to measure the execution speed of the iMXRT MCU? (Like the Profiler Block in the S32 MBDT Toolbox.)
Cheers,
Sam
Hello, @Sam_ECU
Unfortunately, for IMXRT Toolbox we don`t have support for Profiling blocks, but you can measure execution time in PIL simulation directly from Simulink. You can do this by going on Hardware settings tab in your model and then Configuration Parameters -> Code Generation -> Verification -> Code Profiling and enable Measure execution time
After that, you can go to Configuration Parameters -> Hardware Implementation -> Profiling Timers to choose which timer you want to use to measure execution and there are 2 options: PIT or GPT timer.
But you have to enable these settings in top model and also in the referenced models.
Hope this helps.
Best regards,
Stefan.
Hello, @Sam_ECU
Even if we do not support the profiling blocks, I have a sort of approach to measure execution time. For this, you can use the GPT, which is an up-counting timer. The workflow on code perspective would be this:
GPT_StartTimer(GPT_instance);
/* code_to_be_measured */
ticks = GPT_GetCurrentTimerCount(GPT_instance);
GPT_StopTimer(GPT_instance);
So you can put your algorithm you want to measure the time of execution in a subsystem, then you have to add the blocks for starting and stopping the GPT and the Timer Counter Value block to get the ticks from the timer.
In Simulink, to generate the code in the way described upper, you have to put priorities to the blocks. So the TimerStart block has priority 0, Subsystem_To_Measure has priority 1, TimerCounterValue block has priority 2 and TimerStop block has priority 3. To put priorities for each block/subsystem, you have to right-click on a block/subsystem, go to Properties... and introduce the priority in the Priority field.
In the mex file attached to the model, you have to set the GPT timer to run in Free Run Mode in order to let the Timer to count to the maximum value (0xFFFFFFFF) and also enable Reset counter when re-enabled checkbox in order to reset the current counter value to 0 when the GPT_StopTimer function is called.
The current counter value is put in ticks data memory store and it can be visualized in the FreeMASTER project attached.
I have also attached the model. You can check it and see if it suits for your application.
Hope this helps.
Regards,
Stefan.