|
|
View previous topic :: View next topic |
Author |
Message |
SeanB Guest
|
WDT and 16LF88 |
Posted: Mon May 22, 2006 10:46 pm |
|
|
Hi all,
I'm trying to set up the WDT on a 16LF88 using CCS C. The SETUP_WDT
function in CCS doesn't seem to know about these newer parts which
have prescaler settings yielding a WDT timeout period longer than 2.3
seconds (the function documentation only lists values up to 2.304
seconds). Do I have to set this up manually or is there a new function
or new way of doing this in CCS? We have version 3.249 of the CCS
compiler.
Thanks,
Sean |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue May 23, 2006 2:00 pm |
|
|
Apparently CCS only implemented it on some PICs. I made the
test program below to add extended WDT capability to the 16F88.
In the program below, if you press the Enter key about once per
second, the program will not timeout. If you stop pressing the key,
the program will repeatedly do a WDT timeout, about every 2 seconds.
I tested the program with three of the WDT constants and measured
the timeout periods with a stopwatch. The measured periods are
shown below in the comments.
Note that the fuses are set for NOWDT, and you enable the WDT with the
setup_enhanced_wdt() macro. The constants for the timeouts are taken
from one of the other .H files which do have support for long timeouts.
Code: |
#include <16F88.h>
#fuses EC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_B5, rcv=PIN_B2, ERRORS)
#define WDT_ON 1
#define WDT_OFF 0
#define WDT_DIV_32 1
#define WDT_DIV_64 3
#define WDT_DIV_128 5
#define WDT_DIV_256 7
#define WDT_DIV_512 9 // 2 seconds
#define WDT_DIV_1024 11
#define WDT_DIV_2048 13 // 8 seconds
#define WDT_DIV_4096 15
#define WDT_DIV_8192 17
#define WDT_DIV_16394 19
#define WDT_DIV_32768 21
#define WDT_DIV_65536 23 // 260 seconds
#byte WDTCON = 0x105
#define setup_enhanced_wdt(x) WDTCON = x
//===========================
void main(void)
{
setup_enhanced_wdt(WDT_DIV_512);
printf("Hello World\n\r");
while(1)
{
getc();
restart_wdt();
}
} |
|
|
|
SeanB Guest
|
Thank you for WDT help on 16LF88! |
Posted: Tue May 23, 2006 5:26 pm |
|
|
Thank you, PCM Programmer, that was a very helpful reply. |
|
|
|
|
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
|