Timings, Loops - More.


Results 1 to 7 of 7

Threaded View

  1. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Timings, Loops - More.

    Hi,
    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?
    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)

    Is the internal RC oscillator used for the watchdog also used for anything else, i.e. sleep?
    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.

    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.

    ...
    ...
    How do you set this, would you just make the sleep command longer than the expected interupt time?
    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.

    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.
    Last edited by HenrikOlsson; - 5th July 2011 at 18:14.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts