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

PCM - Sets up the watchdog timer

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







PCM - Sets up the watchdog timer
PostPosted: Sat Apr 05, 2003 7:03 pm     Reply with quote

Using the PCM for PIC16F628, how can I increase the time for the watchdog timer, from 2300ms to 10000ms ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 13446
R.J.Hamlett
Guest







Re: PCM - Sets up the watchdog timer
PostPosted: Sun Apr 06, 2003 3:19 am     Reply with quote

:=Using the PCM for PIC16F628, how can I increase the time for the watchdog timer, from 2300ms to 10000ms ?

You can't.
This is a hardware limit, not anything that can be changed by the code. You should not rely even on the 2300mSec, since the time delay varies significantly between chips, and with temperature/voltage etc..
The way to code if you need a long watchdog, is to generate a carefully written 'timer' tick, with an interrupt handler, that decrements a counter, and if the counter is not zero, resets the watchdog. Then in the main code where you would normally do a 'restart_wdt()' call, you instead have a routine to reset the counter, and if this stops happening, when the counter gets to zero, you will get a watchdog. A crude version is below:

//counter for the watchdog
int wtick;

//interrupt routine to handle the 'tick'
#int_timer1
void tick(void) {
//If the wtick value is non zero
if (wtick) {
//decrement wtick
--wtick;
//and reset the hardware watchdog
restart_wdt();
}
}

#define RESET_WDOG() wtick=9

void main() {

setup_counters(RTCC_INTERNAL,WDT_2304MS);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(FALSE);
setup_vref(FALSE);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
while (true) {
/*As set, the 'tick interrupt' will occur every 104mSec,
with a 20MHz processor clock. Setting wtick to 9, will
result in it taking at least 8 seconds to count down. The
hardware watchdog will occur about 2.3 seconds after
this. Hence so long as the counter is reset at least
once every ten seconds the watchdog should not trigger.
You will have to adjust the value used to suit your
crystal frequency. */
RESET_WDOG();
}
}

This is untested, but should work.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 13449
Tibi
Guest







Re: PCM - Sets up the watchdog timer
PostPosted: Sun Apr 06, 2003 4:13 pm     Reply with quote

To R.J.Hamlett

thank you for the answer. I will try to manage the problem in this situation. Any way you sent me good ideas.

Thank you and best regards,

Tibi
___________________________
This message was ported from CCS's old forum
Original Post ID: 13451
R.J.Hamlett
Guest







Re: PCM - Sets up the watchdog timer
PostPosted: Mon Apr 07, 2003 3:48 am     Reply with quote

:=To R.J.Hamlett
:=
:=thank you for the answer. I will try to manage the problem in this situation. Any way you sent me good ideas.
:=
:=Thank you and best regards,
:=
:=Tibi
Good Luck. :-)
___________________________
This message was ported from CCS's old forum
Original Post ID: 13457
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