0
\$\begingroup\$

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?

\$\endgroup\$
  • \$\begingroup\$ The 18F25k20 has an internal 31kHz oscillator - any reason you can't use it? \$\endgroup\$ – Bruce Abbott Feb 27 '18 at 3:36
  • \$\begingroup\$ After using 31 KHz internal oscillator as the primary clock source for timer 1, do I need to put the device in sleep? Would Timer 1 interrupt work with 31 KHz internal oscillator to wake up from sleep? Can I switch over from 20MHz external crystal to internal 31KHz during code execution? What settings would be required for Timer 1 in 31 KHz internal oscillator after switching from 20 MHz, as I use Timer 1 with 20 MHz crystal during rest of the code execution too? \$\endgroup\$ – user101095 Feb 27 '18 at 13:51
  • \$\begingroup\$ In order to switch over from 20 MHz external crystal to 31 KHz internal oscillator, do I need to enable IESO: Internal/External Oscillator Switchover bit in CONFIG1H register? \$\endgroup\$ – user101095 Feb 27 '18 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.