; ; The Watch Dog Timer (WDT) ; ; ; uncomment following two lines if using 16f627 or 16f628. config uses internal oscillator LIST p=16F627 ;tell assembler what chip we are using include "P16F627.inc" ;include the defaults for the chip ; __config 0x3D18 ;sets the configuration settings (oscillator type etc.) __config 0x3D1C ; changed to enable WDT ; Filename: IOExample3Woof.asm ; WDT Watch Dog Timer ; BIG NOTE!!!! We haven't paid attention to the line above (__config). We need to now!! ; This line sets a 14 bit register called the CONFIG register. This register is not ; available thru software!! Look on p. 96 of the reference manual for specifics. ; To enable the WDT, we must set bit 2 to a value of 1. ; You should read tutorial 13 off the class web site ;un-comment the following two lines if using 16f627 or 16f628 OPT equ 0x81 cblock 0x20 count count2 endc bsf STATUS,RP0 ;switch to bank 1 movlw 0x00 movwf TRISB ;make portB output movlw b'11111000 movwf OPT ; set up prescaler 1-1 and for WDT bcf STATUS,RP0 top movlw 0x00 movwf PORTB call delay call delay call delay call delay call delay call delay ; clrwdt movlw 0xff movwf PORTB ; call delay ; call delay ; call delay ; call delay ; clrwdt herex goto herex delay ; 1 ms delay movlw 0xff movwf count x decfsz count goto x movlw 0x4c movwf count y decfsz count goto y return end ********************************************************************************************************** ; uncomment following two lines if using 16f627 or 16f628. config uses internal oscillator LIST p=16F627 ;tell assembler what chip we are using include "P16F627.inc" ;include the defaults for the chip ; __config 0x3D18 ;sets the configuration settings (oscillator type etc.) __config 0x3D1C ; changed to enable WDT ; Filename: IOExample4Woof.asm ; WDT Watch Dog Timer ; BIG NOTE!!!! We haven't paid attention to the line above (__config). We need to now!! ; This line sets a 14 bit register called the CONFIG register. This register is not ; available thru software!! Look on p. 96 of the reference manual for specifics. ; To enable the WDT, we must set bit 2 to a value of 1. ; You should read tutorial 13 off the class web site ;un-comment the following two lines if using 16f627 or 16f628 OPT equ 0x81 cblock 0x20 count count2 endc bsf STATUS,RP0 ;switch to bank 1 movlw 0x00 movwf TRISB ;make portB output movlw b'11111001 movwf OPT ; set up prescaler 2-1 and for WDT bcf STATUS,RP0 top movlw 0x00 movwf PORTB call delay call delay call delay call delay call delay call delay clrwdt movlw 0xff movwf PORTB ; call delay ; call delay ; call delay ; call delay ; clrwdt herex goto herex delay ; 1 ms delay movlw 0xff movwf count x decfsz count goto x movlw 0x4c movwf count y decfsz count goto y return end *************************************************************************************************** ; uncomment following two lines if using 16f627 or 16f628. config uses internal oscillator LIST p=16F627 ;tell assembler what chip we are using include "P16F627.inc" ;include the defaults for the chip ; __config 0x3D18 ;sets the configuration settings (oscillator type etc.) __config 0x3D1C ; changed to enable WDT ; Filename: IOExample5Woof.asm ; WDT Watch Dog Timer ; BIG NOTE!!!! We haven't paid attention to the line above (__config). We need to now!! ; This line sets a 14 bit register called the CONFIG register. This register is not ; available thru software!! Look on p. 96 of the reference manual for specifics. ; To enable the WDT, we must set bit 2 to a value of 1. ; The decumentation says that assert a clrwdt resets the prescaler. ; I am unable to verify this (and I tried!!) ; You should read tutorial 13 off the class web site ;un-comment the following two lines if using 16f627 or 16f628 OPT equ 0x81 cblock 0x20 count count2 endc bsf STATUS,RP0 ;switch to bank 1 movlw 0x00 movwf TRISB ;make portB output movlw b'11111010 movwf OPT ; set up prescaler 4-1 and for WDT bcf STATUS,RP0 top clrwdt movlw 0x00 movwf PORTB call delay call delay call delay call delay call delay call delay call delay call delay movlw 0xff movwf PORTB ; call delay ; call delay ; call delay ; call delay ; clrwdt herex goto herex delay ; 1 ms delay movlw 0xff movwf count x decfsz count goto x movlw 0x4c movwf count y decfsz count goto y return end