Hi,
I believe you are right - sort of. It does reset the PIC but it's a different kind of reset compared to, say, pulling MCLR. If you look in the datasheet (I'm looking at 18F4520 at the moment) you'll find a table called Initialization condition for all registers or something like that. It shows that when the PIC wakes up or "resets" due to an interrupt OR the WDT the internal register contents remains unchanged as opposed to a Power on reset or a MCLR reset. (Exceptions exists)I have noticed that several people refer to the watchdog timing waking up the PIC when in sleep, i thought that the watchdog timer just reset the PIC?
The watchdog timer has its own built in RC oscillator. It does not depend on the osciallator used to clock the program execution - if it did it would be impossible for it to wake the PIC up since the main oscillator is shut down when entering "normal" sleep mode. This RC oscillator is, as far as I know, not callibrated and can drift quite a bit over temperature which is why it's not very good at keeping "real" time.Is the internal RC oscillator used for the watchdog also used for anything else, i.e. sleep?
EDIT: The PBP command Sleep works by keeping track of the number of times that the WDT waked the PIC up. Pretty much as you're doing with your software timers. If the WDT period is 200ms (I've no idea what it really is) and you execute a Sleep 10 the WDT will wake the PIC up 50 times, each time the PBP "system" will increment a counter and when it hits 50 it will countinue executing your code.
That would work. With the PBP command Sleep the specified period is in seconds so if you intend to have a "cycle time" of 25ms then executing a Sleep 1 in your Main routine should do it....
...
How do you set this, would you just make the sleep command longer than the expected interupt time?
On the other hand you could just turn off the WDT all together. Then Sleep (or Nap) will put the PIC to sleep "for ever" - or until something wakes it up which in this case would be your TMR1 interrupt.
Hope that helps.
/Henrik.




Bookmarks