chTimeNow() issue

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
Pask
Posts: 47
Joined: Thu Jun 19, 2014 3:51 pm

chTimeNow() issue

Post by Pask »

hi, i have the following code:

Code: Select all


count = 0;
void function(){
if(count==0)
now=chTimeNow();
if(count==1)
now1=chTimeNow();
count++;
}


i call function() from a thread every 1000 ms and finally read through GDB global var now and now1. Why now is greater than now1?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: chTimeNow() issue

Post by Giovanni »

System time is supposed to wrap back to zero after a while, probably this is what you are seeing.

Giovanni
Pask
Posts: 47
Joined: Thu Jun 19, 2014 3:51 pm

Re: chTimeNow() issue

Post by Pask »

Back to zero in only 1 second? :?
Not 2^32/CH_FREQUENCY seconds?
Pask
Posts: 47
Joined: Thu Jun 19, 2014 3:51 pm

Re: chTimeNow() issue

Post by Pask »

is there a way to get real system time ticks since start?
can someone give me a simple solution? pls
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: chTimeNow() issue

Post by Giovanni »

You should rather ask yourself, is there anything I am doing wrong?

If you read zero the 2nd time it could be an external factor clearing the variable, an overflow, a reset or something else.
Post Reply