meghs94 / tinyos-main

Automatically exported from code.google.com/p/tinyos-main
1 stars 0 forks source link

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

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Test for new OCR* in Atm128*AlarmAsyncP.nc/setOcr*A(). 
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 reported on code.google.com by M.Cerv...@computer.org on 1 Oct 2012 at 9:00

Attachments: