# Can I  change the watchdog pre-scalar value in running code?



## Barjugh (Sep 9, 2016)

Hello,
Is it possible to change the watchdog pre-scalar/post scalar value in running code , not only in the  
config section.
I would like to be able to change the "sleep" time on the fly.
I'm using a pic24F16KA102(here).
Cheers


----------



## slozomby (Sep 9, 2016)

no idea.

but you might try these 2 docs which cover the watchdog timers in detail.

http://ww1.microchip.com/downloads/en/DeviceDoc/70157F.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/39697b.pdf


----------



## Ferrum Master (Sep 9, 2016)

You need to use special function register for that. Never had need to do it, and never used PIC's. But it is possible.


----------



## silentbogo (Sep 17, 2016)

Barjugh said:


> Hello,
> Is it possible to change the watchdog pre-scalar/post scalar value in running code , not only in the
> config section.
> I would like to be able to change the "sleep" time on the fly.
> ...


Have you tried writing to WDTPS?
http://ww1.microchip.com/downloads/en/DeviceDoc/39697b.pdf

Basically you write new 4-bit prescaler value to WDTPS, and then put the device in sleep mode. 
I've never worked with PIC microcontrollers, so I don't know for sure if you need to disable WDT prior to changing its pre/post-scaler.


----------

