CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Watchdog Timer Setup Question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mgiuliani



Joined: 30 Mar 2023
Posts: 14

View user's profile Send private message

Watchdog Timer Setup Question
PostPosted: Tue Feb 20, 2024 12:12 pm     Reply with quote

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: 14

View user's profile Send private message

PostPosted: Tue Feb 20, 2024 1:08 pm     Reply with quote

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: 1903

View user's profile Send private message

PostPosted: Tue Feb 20, 2024 2:27 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group