In one of my application using PIC18F25K20, I set the Watchdog Timer Postscale Select bits as following for the CONFIG2H register at the beginning of the c code under configuration bits.
pragma config WDTPS = 1024 // Watchdog Timer Postscale Select bits (1024 * 4 mS = 4 SEC TIMER)
Now during run time in the code, I need to reduce the watch dog timer expiration time from 4 sec to 250mS. In order to do this, I need to change these WDTPS postscale bits in run time (only once).
Is it possible? If so, please advise how to do this..
What I am trying to do is as follow:
In one point during code execution, I want to put PIC in sleep. After 250 mS, PIC should wake up and do software reset using RESET instruction to reset the PIC. I don't have 555 or any other means to time this duration. No external interrupt would be possible as this is just software delay before RESET in sleep mode (to save battery power). I am using 20MHz external crystal and do not have any separate Timer 1 crystal for clocking in sleep mode. So, I can only think of Watch Dog timer to wake up PIC after 250mS to perform RESET. Any other thoughts?