View previous topic :: View next topic |
Author |
Message |
mgiuliani
Joined: 30 Mar 2023 Posts: 20
|
Watchdog Timer Setup Question |
Posted: Tue Feb 20, 2024 12:12 pm |
|
|
I'm working with a PIC24FJ1024GB610 device that has the following fuses set for the WDT:
#fuses WPOSTS16
#fuses WDT128
#FUSES NOWDT
#fuses WINDIS
#fuses NOWDTCMX
In the application code, the device uses setup_wdt(WDT_ON); to enable the WDT at bootup and restart_wdt (); to reset the timer after each loop of the main loop.
My confusion is with NOWDT. To me that means that the WDT is disabled entirely period, but the documentation says that it just allows your code to control when it's enabled or disabled. In reality, with the code like this the WDT is not resetting the device at all. If I change NOWDT to WDT, it works as it should. What am I misunderstanding? |
|
|
mgiuliani
Joined: 30 Mar 2023 Posts: 20
|
|
Posted: Tue Feb 20, 2024 1:08 pm |
|
|
Answered my own question in the mean time. At least for the type of PIC I'm using, you have to set the fuse WDT_SW to control the WDT with your code. NO_WDT turns it off permanently and WDT turns it on permanently. So for what this code I'm working with wants to do, I need these fuses.
#fuses WPOSTS16
#fuses WDT128
#FUSES WDT_SW
#fuses WINDIS
#fuses NOWDTCMX
Then setup_wdt(WDT_ON) at bootup to start it and restart_wdt(); to reset it. If I ever want to turn it off, use setup_wdt(WDT_OFF);. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1909
|
|
Posted: Tue Feb 20, 2024 2:27 pm |
|
|
Glad you figured it out.
I would like to caution you not to put too much trust into the WDT's timeout - it's not terribly accurate. There are large chip-chip variances as well as generally poor temperature stability. |
|
|
|