Hi,
I want to measure the execution time for my application based on MBDT KVx.
How can I do this one?
Solved! Go to Solution.
Hi @CauTran ,
We currently don't have enabled for the toolbox the Code execution profiling support, but you can try to use the Timer blocks to measure the execution time of a subsystem.
You can configure for e.g the PIT timer from MCUX configuration Tool in free running mode (set the period to the max value)
In the model, place all your code in a subsystem for e.g; add the Start/Stop Timer block - one block that will start the timer and another to stop the timer and a register read block to read the CVAL0 value (if channel 0 enabled). Add priorities to the blocks and subsystems (right click on the block/subsystem and set Priority)- Start Timer higher priority ( 0 - is highest priority), then your subsystem that you want to measure, the Read Register block and last Stop Timer block. You need to read first the CVAL0 register and then stop the Timer, because the StopTimer call will reset the registers.
And to get number of ticks you just need to substract from max timer value the value of CVAL0 (PIT timer counts down - at start is equal with period set in configuration tool and goes down from there).
Hope this helps,
Alexandra
Hi @CauTran ,
See attached the example. It has also a freemaster block to see the counted ticks variable.
BR,
Alexandra
Hi @CauTran ,
We currently don't have enabled for the toolbox the Code execution profiling support, but you can try to use the Timer blocks to measure the execution time of a subsystem.
You can configure for e.g the PIT timer from MCUX configuration Tool in free running mode (set the period to the max value)
In the model, place all your code in a subsystem for e.g; add the Start/Stop Timer block - one block that will start the timer and another to stop the timer and a register read block to read the CVAL0 value (if channel 0 enabled). Add priorities to the blocks and subsystems (right click on the block/subsystem and set Priority)- Start Timer higher priority ( 0 - is highest priority), then your subsystem that you want to measure, the Read Register block and last Stop Timer block. You need to read first the CVAL0 register and then stop the Timer, because the StopTimer call will reset the registers.
And to get number of ticks you just need to substract from max timer value the value of CVAL0 (PIT timer counts down - at start is equal with period set in configuration tool and goes down from there).
Hope this helps,
Alexandra