Time measure
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Time measure
Because there is a problem somewhere not evident in the code you posted, the time should increase continuously.
Giovanni
Giovanni
Re: Time measure
If granularity on the scale of a second is good enough, use the RTC_EVENT_SECOND :
Code: Select all
//seconds since boot tracker
uint32_t secondsSinceBoot = 0;
static void RTC_callback(RTCDriver *rtcp, rtcevent_t event) {
(void)rtcp;
switch (event) {
case RTC_EVENT_OVERFLOW: break;
case RTC_EVENT_SECOND: /* every second update code here */
secondsSinceBoot++;
break;
case RTC_EVENT_ALARM: break;
default: break;
}
}
//somewhere in your initialisation:
rtcSetCallback(&RTCD1, RTC_callback);
...
Re: Time measure
Giovanni wrote:Because there is a problem somewhere not evident in the code you posted, the time should increase continuously.
Giovanni
i don't understand. How can i do
if(chTimeNow()>MS2ST(10))
do...
???
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Time measure
chTimeNow() returns the value of a counter that is increased by a timer so:
1) Check that interrupts are enabled where you perform the check.
2) Make sure the timer is working.
If you want detailed help then give context, hint, 2 lines of code are not sufficient.
Giovanni
1) Check that interrupts are enabled where you perform the check.
2) Make sure the timer is working.
If you want detailed help then give context, hint, 2 lines of code are not sufficient.
Giovanni