Part Number: CC2538DK
Other Parts Discussed in Thread: CC2538
Hello,
I am using Contiki-OS with CC2538DK to do some experiment.
I found out that some time system's clock will have strange behavior.
Contiki get CC2538's sleep timer value to calculate system time using following code:
rtimer_clock_t
rtimer_arch_now()
{
rtimer_clock_t rv;
/* SMWDTHROSC_ST0 latches ST[1:3] and must be read first */
rv = REG(SMWDTHROSC_ST0);
rv |= (REG(SMWDTHROSC_ST1) << 8);
rv |= (REG(SMWDTHROSC_ST2) << 16);
rv |= (REG(SMWDTHROSC_ST3) << 24);
return rv;
}
(

)
However, it seem like the sleep timer won't increase every time i get the value. it will go backward sometime.
EX:
First time i get the value: 1231018689
and the next time i get the value: 1231018688
This will mess up the clock time calculation.
How do i solve this issue?
Thanks