Się wgłębię, żeby nie było wątpliwości.
Kod:
Do wybudzania uC z powerdown używany watchdog.
Wg helpa Bascom:
Quote: CONFIG WATCHDOG = czas
gdzie:
czas czas w milisekundach po jakim układ WATCHDOG uaktywni
sygnał reset procesora. Możliwe są wartości: 16 , 32, 64 , 128 ,
256 , 512 , 1024 oraz 2048.
Więc rzeczywiście mamy 2s. Jak teraz oszukamy procka i ustawimy wolniejszy kwarc to owszem, może i rzadziej się wybudzi, ale inne wbudowane funkcje zależne czasowo przestaną działać.
Żeby jeszcze $NORAMCLEAR chciała zadziałać (dłuższe czasy wysnaczane przez inkrementację zmiennej do wyznaczonej wartości), tak jak założyłem (po wyjściu z powerdown zmienne nie będą kasowane). Ale niestety tak to działać nie chce.
[/quote]
---edit---
Z helpa najnowszej wersji:
Quote: The interval constant in mS the watchdog timer will count to before it will reset your program.
Possible settings :
16 , 32, 64 , 128 , 256 , 512 , 1024 and 2048.
Some newer chips : 4096, 8192.
The XMEGA has a 1 KHz clocked watchdog. For Xmega the following value in millisecond need to be used :
8 ,16,32,64,125,250,500,1000,2000,4000,8000
So 2000 will sets a timeout of 2 seconds.
Note that some new AVR's might have additional reset values such as 4096 and 8192.
When the WD is started, a reset will occur after the specified number of mS.
With 2048, a reset will occur after 2 seconds, so you need to reset the WD in your programs periodically with the RESET WATCHDOG statement.
Some AVR's might have the WD timer enabled by default. You can change this with the Fuse Bits.
After the CONFIG WATCHDOG statement, the watchdog timer is disabled. You can also use CONFIG WATCHDOG to change the time out value. This will stop the watchdog timer and load the new value.
After a CONFIG WATCHDOG, you always need to start the Watchdog with the START WATCHDOG statement.
Most new AVR chips have an MCUSR register that contains some flags. One of the flags is the WDRF bit. This bit is set when the chip was reset by a Watchdog overflow. The CONFIG WATCHDOG will clear this bit, providing that the register and bit is available in the micro.
When it is important to examine at startup if the micro was reset by a Watchdog overflow, you need to examine this MCUSR.WDRF flag before you use CONFIG WATCHDOG, since that will clear the flag.
For chips that have an enhanced WD timer, the WD timer is cleared as part of the chip initialize procedure. This because otherwise the WD timer will only work once. If it is important that you know the cause of the reset, you can read the register R0 before you run other code.
Z resztą czy to będzie 2s czy 8s to w sumie kwestia na tę chwilę drugorzędna. Procek musi wykonać akcję raz na godzinę. Problem jest na razie taki, że nie za bardzo wiem jak nie utracić zawartości inkrementowanej zmiennej po wyjściu z powerdown (po zadziałaniu watchdoga, który w zasadzie nie robi nic innego jak właśnie generuje reset...)