Jonny!!! - 2008-08-18

I've been trying to figure out how to get the WDT to reset every 268 seconds, and under. How do I accomplish this?

The data sheet says this: ( http://ww1.microchip.com/downloads/en/DeviceDoc/41262E.pdf )
"Enhanced Low-Current Watchdog Timer (WDT)
with On-Chip Oscillator (Software selectable
nominal 268 Seconds with Full Prescaler) with
Software Enable" (section 14.5)

From what I undestand from the datasheet, the WDT and Timer1 prescaler are assigned with different registers. Timer 1 is set through the OPTION_REG, and the WDT is set through the WDTCON register.

Am this correct? Because the WDT times out approx. every 3 seconds, no matter what I set the prescalers on both registers to. The datasheet also mentions postscalers. What are postscalers?

Thank you.

My code:

'14.5.2 WDT CONTROL
'The WDTE bit is located in the Configuration Word
'register. When set, the WDT runs continuously.
'When the WDTE bit in the Configuration Word register
'is set, the SWDTEN bit of the WDTCON register has no
'effect. If WDTE is clear, then the SWDTEN bit can be
'used to enable and disable the WDT. Setting the bit will
'enable it and clearing the bit will disable it

'allow it to disable WDT. Otherwise it will reset during sleep!
'Turn off WDT before sleep.

'14.5.2 WDT CONTROL
'The WDTE bit is located in the Configuration Word
'register. When set, the WDT runs continuously.
'When the WDTE bit in the Configuration Word register
'is set, the SWDTEN bit of the WDTCON register has no
'effect. If WDTE is clear, then the SWDTEN bit can be
'used to enable and disable the WDT. Setting the bit will
'enable it and clearing the bit will disable it

'allow it to disable WDT. Otherwise it will reset during sleep!
'Turn off WDT before sleep.

#chip 16F690, 4
#config FCMEN = OFF 'Fail-Safe Clock Monitor Enabled bit 
#config IESO = OFF 'IESO: Internal External Switchover bit 
#config BOR = OFF 'Brown-out Reset Selection bits 
#config CPD = OFF 'Data Code Protection bit 
#config CP = OFF 'Code Protection bit 
#config MCLRE = On 'MCLR Pin Function Select bit 
#config PWRTE = OFF 'Power-up Timer Enable bit 
#config WDT = On 'Watchdog Timer Enable bit 
#config Osc = INTOSC 'Oscillator Selection bits 

'LCD constants:
#define LCD_IO 4 '4 bit
#define LCD_RS PORTC.1
#define LCD_RW PORTC.0
#define LCD_Enable PORTA.2
#define LCD_DB4 PORTC.2
#define LCD_DB5 PORTB.4
#define LCD_DB6 PORTB.5
#define LCD_DB7 PORTB.6
'end of LCD constants

goto main
WDTCON = b'---01011' '1011 = 1:65536
'WDTCON.SWDTEN = 1 'Temp. enable WDT.
'OPTION_REG = b'00001111' 'prescaler assigned to WDT with 1 to 128 prescaler
main:
wait 100 ms
clrwdt
cls
print "Program start"
wait 50 10ms
clrwdt

    cls
    print "waiting"
    wait 5 s
    cls
    print "next line" 'wdt lasted longer the 5 seconds