Measure Run time of a function in TC399

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
AC2
Level 2
Level 2
10 questions asked 5 replies posted 10 sign-ins

Hello,

I need to measure run time of a function on TC399. For that, I am making use of GPT12 timer module. 

I have written the following snippet.

initial_value = IfxGpt12_T3_getTimerValue(&MODULE_GPT120);

My_custom_function();

final_value = IfxGpt12_T3_getTimerValue(&MODULE_GPT120);

// Note: I have set the timer direction down.

// Calculate the elapsed timer ticks
if (final_value <= initial_value) {
elapsedTicks = initial_value - final_value ;
} else {
// Timer has wrapped around :: MAX_VALUE=0xFFFF; 
elapsedTicks = (MAX_VALUE - final_value ) + initial_value + 1;
}

uint32 timerFrequency = IfxGpt12_T3_getFrequency(&MODULE_GPT120);
uint32 elapsedMilliseconds = (elapsedTicks * 1000) / timerFrequency;

 


However, sometimes, the run time value is showed as 0ms. I am sure, there is something going wrong. Can you please help me?

Also, does  'IfxGpt12_T3_getTimerValue' this return ticks? 

Please guide me through the process.
Thanks in advance!

0 Likes
1 Solution
DownyK
Level 5
Level 5
100 replies posted 10 solutions authored 250 sign-ins

Hi @AC2 

How about getting STM timer from STMX.TIM.X.U? 

in my case, for calculating function runtime, accessing STM module directly.

it is working  well

View solution in original post

0 Likes
3 Replies
AC2
Level 2
Level 2
10 questions asked 5 replies posted 10 sign-ins

Hi,

Can I please get some support? 

Thanks in advance! 🙂

0 Likes
DownyK
Level 5
Level 5
100 replies posted 10 solutions authored 250 sign-ins

Hi @AC2 

How about getting STM timer from STMX.TIM.X.U? 

in my case, for calculating function runtime, accessing STM module directly.

it is working  well

0 Likes
AC2
Level 2
Level 2
10 questions asked 5 replies posted 10 sign-ins

@DownyK  Thanks for the lead! 🙂 It works.

0 Likes