iMXRT: Profiling and Execution Speed

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iMXRT: Profiling and Execution Speed

1,182 Views
Sam_ECU
Contributor IV

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

0 Kudos
3 Replies

1,165 Views
stefancinipeanu
NXP Employee
NXP Employee

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

stefancinipeanu_0-1653030387173.png

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.

stefancinipeanu_1-1653030912689.png

But you have to enable these settings in top model and also in the referenced models.

Hope this helps.

Best regards,

Stefan.

0 Kudos

1,153 Views
stefancinipeanu
NXP Employee
NXP Employee

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.

stefancinipeanu_1-1653044007064.png

 

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.

stefancinipeanu_0-1653043934517.png

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.

stefancinipeanu_2-1653044387815.png

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.

 

 

 

0 Kudos

1,135 Views
Sam_ECU
Contributor IV

Hello @stefancinipeanu 

Thanks for the response I'll look into it.

Regards,

Sam

0 Kudos