Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Watchdog timer Postscaler Query

Status
Not open for further replies.

fairiesrcrazies

New Member
Hi,
In relation to the setting up of using the postscaler for using the watchdog timer for sleep.
I'm using the internal oscillator at 4MHz and I have the postscaler set up to 1:256 which I know puts my PIC to sleep for around 4s. I only know this value through trial and error
But what I don't know is how to calculate to the postscaler value. Say for example I want the PIC to got to sleep for an hour....what is the formula for finding this out?????..

Could really use some help

The PIC I'm using is in the link below (PIC 18f4620)

https://ww1.microchip.com/downloads/en/DeviceDoc/39626e.pdf
 
Normally the watchdog has it's own timer, which is nothing to do with your 4MHz internal osc.

The watchdog period should be discussed in the datasheet, then all that is necessary is to set the watchdog prescaler to get a longer time, for example a second.

Then if you want the PIC to sleep for an hour, you use the watchdog to sleep for a second at a time, then it wakes up after each second and you count one more second done. Obviously after 3600 seconds are done you have 1 hour. :)
 
So what your saying is if I have the postscaler set to a value of four seconds...I then put that in a continuous loop until it counts down from say 900..Then exit the loop on completion
I should have my hour.
I taught it was just a matter of changing the postscaler value to give me the relevant time for the watchdog timer
Also If I do as you say will the PIC be able to count down the number as all timers are switched off due to being in sleep mode??????
 
what are you trying to do? is it just to get maxium power saving or something else? the postscaler will give you a period from 4ms upto 131second's (ish)
look at page 254 of the datasheet bits 4-1 set the postscaler all four bits 1's is around 131 seconds.
jason
 
im using it for power saving...You see im having trouble understanding the values of the postscaler..I have the postscaler set to 256 which is around 4s....But I have no idea how to understand where that value came from...Is there a formula there to translate does values into seconds????:confused::confused:
 
i think the post scaler is ratiometric so you have it set to 4ms x 256 if you look at the table it say 1:xxxx but reading the datasheet it tells you that certain conditions reset the postscaler so you will have to have a good look through your code to make sure you dont reset when you dont want to
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top