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 CCS Technical Support

PIC24 and #FUSES WDT time values?

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



Joined: 17 Jun 2019
Posts: 617
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PIC24 and #FUSES WDT time values?
PostPosted: Sun Jan 26, 2025 7:19 pm     Reply with quote

The root problem I am trying to solve is to write out Configuration Bytes with a watchdog timer, so if things lock up it will reboot.

I am using a program that writes out a new program using write_program_memory(), and then it does a reset_cpu() but it locks up (I see the siow IDT console just printing "r" over and over).

BUT, if I use the CCS Device Programmer program to read the entire memory of this chip to a file, then later push that .hex to the part, it starts up and runs just fine. My update is working, but the reset is not.

I thought maybe I could enable a 4 second timer in the fuses somehow, but the WDT4096, etc. do not apply to a PIC24 (PCD?) system.

Is it possible to set watchdog time in #FUSES on a PIC24?
_________________
Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?

Using: 24FJ256GA106, 24EP256GP202 and 24FJ64GA002.
Ttelmah



Joined: 11 Mar 2010
Posts: 19649

View user's profile Send private message

PostPosted: Mon Jan 27, 2025 2:50 am     Reply with quote

Yes. Of course.
If fact the time is always set in the fuses. However big caveat the times
are not very accurate. On some of the older PIC18's, the times can vary
by a factor of 3:1!... However on the PIC24's, they normally only vary by
a few percent. On these chips, there are often different routes to a
particular time, so you have division factors, and post scalers combined
to give a particular time.

However key thing to understand is the time, is distinct from the enable.
There are three different settings for the enable in the fuses:
ON. The watchdog starts at band is permanately on. It cannot be stopped
by the software.
OFF. The watchdog is off, _but can then be enabled/disabled in the software_.
Software ON. With this used on a chip that has the fuse set 'OFF', the
watchdog is enabled, and can then be disabled again in software.
The last is generally the more useful format.

You then have the windowing options. On chips with the 'windowed
watchdog', restart_wdt, must fall inside the window time to work. With this
you have to be very careful that you know how long things will take to
ensure the restart_wdt is in the window.

The watchdog timings cannot be changed in software, they are fuse only
options. If you try to set a time in the setup_wdt instruction, all this
does is set the fuses to match the required time. Hence it'll give a warning
if you try to set two different times in two different places.

Now from what you describe, i'd say let the compiler do this. Just add the
line setup_wdt(WDT_ON | WDT_4S); before the section where you want
the timeout. You will then find the compiler will add the settings to give
the required time in the fuses, but will leave the watchdog off, so it can
then be enabled by this line. If you really must set the fuse combinations
yourself, you will need to sit down with the data sheet, and calculate the
settings for this time.

DS39697, has the table CCS use for this. There are two different routes
to 4 seconds. So, 1024, with a 7 bit pre-scaler, or 4096 with a 5 bit one.
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