Hi,

Usually a clock on a microcontroller is implemented by using a clock
crystal on an asynchronous counter. When the counter overflows (or
reaches 0) it generates an interrupt, which is then used to update the
clock. A typical frequency for such a crystal would be 32.768 kHz, which
is 2^15.

The obvious assumption would be that TinyOS sets the asynchronous
counter such that it generates an interrupt every 32 crystal cycles, or
in other words every 1/1024th of a second. This is quite close to, but
not exactly, 1ms. For this reason you'll have to specify 1024 to get a
1s timer. To get a 1min timer, it would be 60*1024 = 61440.

Cheers,
Urs


Muhammad Azhar schrieb:
> Hi all,
> 
>    I apologise if this is a rather basic question, but to set a timer to fire 
> exactly 1s periodically (using Timer<TMilli>), do I input startPeriodic(1000) 
> or 
> startPeriodic(1024)?  'Coz all the while, I've always used the former, but I 
> realised that it's never 1 sec, always faster than that.  A colleague told me 
> that using 1024 would make the timer fire every 1 sec, but didn't explain 
> why.  
> Thus, I'd like to clarify with you guys.  How exactly does the 1024 convert 
> to 
> 1s?  What if I'd like a timer of 1min then?
> 
>    Many thanks for your help.
> 
> Regards,
> Azhar
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to