[FX3] Get Time Spent?

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

cross mob
HuYa_4249091
Level 4
Level 4
25 replies posted 25 sign-ins 10 replies posted

Hi, I used the time.h to get the snippet code's time spent by C on PC, and it worked:

#include <time.h>
//in some function:
clock_t
start, end;
start = clock();
//some code...
end = clock();
float diff = end - start; //ms

 However, while testing the above code on FX3, the compiler showed error:

timesr.c:(.text+0x8): undefined reference to `_times'
collect2.exe: error: ld returned 1 exit status
cs-make: *** [Rheia.elf] Error 1

How to solve that? Or I need to use other way on FX3?

Any help will be highly appreciated!

0 Likes
1 Solution
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

It seems that you are trying to  get the execution time of the code using the timer ticks. 

If yes, please let me know if  you can you try using the CyU3PGetTime API from the FX3 SDK to get the number of elapsed OS timer ticks and based on that you would get the execution time in millisecond.

I just came across similar query on a forum

Regards,
Rashi

View solution in original post

3 Replies
Rashi_Vatsa
Moderator
Moderator
Moderator
5 likes given 500 solutions authored 1000 replies posted

Hello,

It seems that you are trying to  get the execution time of the code using the timer ticks. 

If yes, please let me know if  you can you try using the CyU3PGetTime API from the FX3 SDK to get the number of elapsed OS timer ticks and based on that you would get the execution time in millisecond.

I just came across similar query on a forum

Regards,
Rashi

Dear Rashi:

Thanks for your reply!

That's what I need!
The user guide describes the CyU3PGetTime( )'s return value is tick count.
But I'm not sure what is tick count...
After researching the relative articles, it seems that the unit is millisecond.
I want to confirm whether the unit is always millisecond for the CyU3PGetTime( )?
By the way, my master clock is 403.2MHz.

Thanks!
Hughes

0 Likes

Hello Hughes,

Please refer to this KBA  EZ-USB® FX3™ Timer Ticks – KBA93074 - Cypress Developer Community   which mentions the default value of  timer tick.

Yes, CyU3PGetTime  returns the number of elapsed OS timer ticks since the FX3 OS was started up. As per the above KBA, the minimum timer tick value can be configured is 1 ms

 

Regards,
Rashi