tinyos / tinyos-main

Main development repository for TinyOS (an OS for embedded, wireless devices).
1.4k stars 516 forks source link

AVR overflow in async timer (used for 32kHz/milli timers) that deadly influence VirtualizeTimerC/TimerMilliC #149

Open tinyos-issues opened 11 years ago

tinyos-issues commented 11 years ago

Original author: M.Cerv...@computer.org (October 01, 2012 21:00:04)

What steps will reproduce the problem?

Test for new OCR* in Atm128_AlarmAsyncP.nc/setOcrA(). It should be always lower than TCNT* when set. If not, the comparator (OCR) does not match and counter (TCNT_) counts to MAX.

The Counter.get() returns higher (base+TCNT) time than it is returned after wrap (base+OCR). This behavior totally destroys VirtualizeTimerC ("t0" becomes grater than "now") and leads to endless posting of "fired" timers until 32bit wrap-up.

The situation is observable only at higher load (for example 2_uart56k+6_timers+unoptimized code leads to overflow every minute and destruction of VirtualizeTimerC "t0" every 3-6minutes).

What version of the product are you using? On what operating system?

actual svn from code.google.com

Please provide any additional information below.

Specification ATmega640/1280/1281/2560/2561, 19.4.2 Clear Timer on Compare Match (CTC) Mode: .... If the new value written to OCR2A is lower than the current value of TCNT2, the counter will miss the compare match. The counter will then have to count to its maximum value (0xFF) and wrap around starting at 0x00 before the compare match can occur. ...

Original issue: http://code.google.com/p/tinyos-main/issues/detail?id=146

phil-levis commented 10 years ago

Is this closed?

cire831 commented 10 years ago

nope