|
|
View previous topic :: View next topic |
Author |
Message |
[email protected]
Joined: 16 May 2006 Posts: 39
|
12F629 WDT |
Posted: Tue Feb 09, 2010 1:41 am |
|
|
What will be instruction being executed after sleep() command and being wakeup by the watchdog timer? The first instruction (all variables will be reset) or the instruction after the sleep() command?
I need to setup a 30 minutes timer but need to be running at very low power (Normal power is 1mA when not sleeping is far too high). If he wakeup can preserver the variable, I can use the variable to count up how many wakeup and sum up the time.
Any advice? |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Tue Feb 09, 2010 7:17 am |
|
|
Section 9.7 (page 66) of the Datasheet has the answer you are looking for.
Quote: | When the SLEEP instruction is being executed, the
next instruction (PC + 1) is pre-fetched. For the device
to wake-up through an interrupt event, the corresponding
interrupt enable bit must be set (enabled). Wake-up
is regardless of the state of the GIE bit. If the GIE bit is
clear (disabled), the device continues execution at the
instruction after the SLEEP instruction. If the GIE bit is
set (enabled), the device executes the instruction after
the SLEEP instruction, then branches to the interrupt
address (0004h). In cases where the execution of the
instruction following SLEEP is not desirable, the user
should have an NOP after the SLEEP instruction.
|
_________________ Google and Forum Search are some of your best tools!!!! |
|
|
Ttelmah Guest
|
|
Posted: Tue Feb 09, 2010 7:57 am |
|
|
What you post, is the 'answer' for a normal interrupt wakeup, but the poster, is asking about a watchdog wakeup from sleep.
This is not obvious if you think about it, since the whole point of the watchdog, is normally to reset the chip.
It is hidden away, in table 9-6 of the data sheet, where you have a WDT wake-up shown as executing the instruction at PC+1, and in the text of section 9-6 (rather than 9.7), where you have:
"During normal operation, a WDT
time-out generates a device RESET. If the device is in
SLEEP mode, a WDT time-out causes the device to
wake-up and continue with normal operation. The WDT
can be permanently disabled by programming the configuration
bit WDTE as clear (Section 9.1)."
So the answer is the same (it executes the next instruction).
Beware though, that the timing accuracy of this will be terrible. The watchdog period, is nominally between 7, and 33mSec, 'nominally' 18mSec, giving a nearly 5:1 timing range. You are not going to get anything approaching an accurate time with this.....
Best Wishes |
|
|
Guest
|
|
Posted: Wed Feb 10, 2010 2:59 am |
|
|
Thanks.
How to set WDTE is clear?
Rgds. |
|
|
Ttelmah Guest
|
|
Posted: Wed Feb 10, 2010 3:19 am |
|
|
It is a _configuration bit_ (fuse).
You can't change it during program execution. You have to elect to have the watchdog enabled, or disabled, in the fuses for the chip. WDT, or NOWDT.
With it enabled, it'll reset the chip, if the watchdog timer times out, during normal execution, or wake the chip if asleep. Disabled, neither of these will happen.
Note also, that executing the 'sleep' instruction, automatically clears the watchdog timer.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|