Hi all,
I have a simple project/code which the micro keeps flashing a LED.
Now I'm trying to add a Watchdog Timer to the code but I'm really stuck.
The code I have to flash the LED is below, and it works perfectly:
So, could anyone show me how to add the WDT?
I've seen other posts and tried some bits of code but I can't really understand.
Thanks in advance.
I have a simple project/code which the micro keeps flashing a LED.
Now I'm trying to add a Watchdog Timer to the code but I'm really stuck.
The code I have to flash the LED is below, and it works perfectly:
Code:
list P = 16F877
;
include "P16f877.inc" ; use definition file for 16F877
;
; --------------------
; USER RAM DEFINITIONS
; --------------------
;
CBLOCK 0x20 ; RAM starts at address 20h
NaHi
NaLo
NbHi
NbLo
ENDC
;
org 0x0000 ; start address = 0000h
; INITIALISE PORTS
; binary used to see individual pin level
movlw b'00000000' ; all port pins = low
movwf PORTA
movlw b'00000000'
movwf PORTB
movlw b'00000000'
movwf PORTC
movlw b'00000000'
movwf PORTD
movlw b'00000000'
movwf PORTE
bsf STATUS,RP0 ; set RAM Page 1 for TRIS registers
; INITIALISE PORTS
; binary used to see individual pin IO status
movlw b'00000000' ; all IO pins = outputs
movwf TRISA
movlw b'00000000'
movwf TRISB
movlw b'00000000'
movwf TRISC
movlw b'00000000'
movwf TRISD
movlw b'00000000'
movwf TRISE
movlw b'00000110' ; all analog pins = digital
movwf ADCON1
bcf STATUS,RP0 ; back to RAM page 0
; LED FLASH LOOP
Loop bsf PORTC,4 ; RC4 = high = led on
call Delay
bcf PORTC,4 ; RC4 = low = led off
call Delay
goto Loop
; 1/2 SEC DELAY SUBROUTINE WITH 4MHz CLOCK
Delay movlw 01h
movwf NbHi
movlw 03h
movwf NbLo
movlw 8Ah
movwf NaHi
movlw 5Bh
movwf NaLo
DeLoop0 decfsz NaLo,F
goto DeLoop0
decfsz NaHi,F
goto DeLoop0
decfsz NbLo,F
goto DeLoop0
decfsz NbHi,F
goto DeLoop0
;
return
end
So, could anyone show me how to add the WDT?
I've seen other posts and tried some bits of code but I can't really understand.
Thanks in advance.