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

Watchdoch timer...

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







Watchdoch timer...
PostPosted: Fri Oct 28, 2005 8:44 am     Reply with quote

Hi i am using pic18f6585 and i want to use the watchdog timer. the normal fuse for that is:WDT128. i think this prescaler counts ~2secs after the wdt will ingnite.now i saw that in 18f6585.h : WDT2048,WDT4096,WDT8192,WDT16384,WDT32768 Does that mean that the watchdog timer can count longer than only 2 seconds? an how do i have to implement that? what if my bootloader is set to WDT,WDT128 and i want to set another value in my program?
Ttelmah
Guest







PostPosted: Fri Oct 28, 2005 10:36 am     Reply with quote

Start by looking at the chip's data sheet. Here you will see, that it supports postscalers for the watchdog, up to 32768. The exta fuses then make sense. You will also find that the watchdog can be enabled/disabled from code, by setting/clearing the SWDTEN bit (makes sense of the 'WDT_ON', and WDT_OFF' values for 'setup_wdt'). However you will also find that the postscaler cannot be changed, except by reprogramming, so you can't change the speed on the 'fly'...
Remember though, there is nothing to stop you from implementing a software counter in a timer interrupt, with something like:
Code:

int16 wdog;

#int_timer2
void tick_int(void) {
   if (wdog) {
       --wdog;
       restart_wdt();
   }
}


Then if you have this called very hundredth of a second (say), and the watchdog set to trigger at a nominal 36mSec, you can change the watchdog 'speed', by just re-setting the counter to a different value. Instead of 'restart_wdt', in your code, use:
Code:

#define RESET_1SEC wdog=98L
#define RESET_10SEC wdog=998L
#define RESET_10SEC wdog=9998L


Then 'RESET_1SEC', will give a guaranteed 'hold' on the watchdog, for just over 1 second. The others do the same for 10, and 100 seconds.

Best Wishes
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