_time_get - Problem (MCF52259 + MQX 3.5)

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

_time_get - Problem (MCF52259 + MQX 3.5)

2,055 Views
sven_kaemmer
Contributor III

Hello,

 

I have a problem with the functions _time_get(), _time_get_elapsed(), _time_diff(). Sometimes, every 5 to 10 seconds, I get a wrong timestamp from these functions. 

 

 

_time_get_elapsed(&start_time);

...

_time_get_elapsed(&end_time);
_time_diff(&start_time, &end_time, &diff_time);

printf("start_time.SECONDS = %u, start_time.MILLISECONDS = %u\n", start_time.SECONDS, start_time.MILLISECONDS );
printf("end_time.SECONDS   = %u, end_time.MILLISECONDS   = %u\n", end_time.SECONDS,   end_time.MILLISECONDS );
printf("diff_time.SECONDS  = %u, diff_time.MILLISECONDS  = %u\n", diff_time.SECONDS,  diff_time.MILLISECONDS );
 

 

 

 

0 Kudos
4 Replies

399 Views
CarlFST60L
Senior Contributor II

Did you work it out?

 

I think I recall some problems similar to you in the past, but they were my code issues...

 

This is how I have been working out the time difference (not sure if its better, but i know it works 100%):

 

            _time_get(&StartTime);            //Check the current time

... Do something that takes time

 

            _time_get(&CurrentTime);            //Check the current time
            _time_diff(&StartTime, &CurrentTime, &TimeDifference);
            printf("Time %u:%u`n", TimeDifference.SECONDS, TimeDifference.MILLISECONDS);

0 Kudos

399 Views
sven_kaemmer
Contributor III

Yes, but I do it in another way. I think, I've always tried your version, but sometimes (every few minutes) I get an error. Now I use tick_time-structs and functions and everything is ok. Perhaps there was another failure and your code would run also. Thanks for your replay.

 

 

_time_get_elapsed_ticks(&start_tick);...do something......_time_get_elapsed_ticks(&end_tick);_time_diff_ticks(&end_tick, &start_tick, &diff_tick);_ticks_to_time(&diff_tick, &diff_time);msec = (diff_time.SECONDS * 1000) + diff_time.MILLISECONDS;printf("...

 

 

0 Kudos

399 Views
JuroV
NXP Employee
NXP Employee

Guys, this can be some MQX bug, if you both encountered the same issue.

Nevertheless, I was running a test app here for 1 hour without the problem found.

0 Kudos

399 Views
Class_Five
Contributor II

This might be related.

 

I started using _time_get and _time_to_date to create reporting timestamps, using the MCF52259 evb, but the result of _time_get was like a random number generator. I also tried after initializing with _time_set, but no change. Then I tried _time_get_ticks and _time_ticks_to_xdate, and this produces consistent results.

0 Kudos