LED blinking Using Watch-dog Timer


Using Watch-dog Timer

This example describes how the watch-dog timer should not operate. The watch-dog timer is properly adjusted (nominal time for counting is 1024mS), but instruction used to reset it is intentionally left out so that this timer always "wins". As a result, the microcontroller is reset (state in registers remains unchanged), program starts execution from the beginning and the number in register R3 is incremented by 1 and then copied to port P1.
LEDs display this number in binary format...

;* DESCRIPTION : After watch-dog reset, program increments number in
;* register R3 and shows it on port P1 in binary format.


WMCON     DATA    96H
WDTEN     EQU     00000001B        ; Watch-dog timer is enabled
PERIOD    EQU     11000000B        ; Nominal Watch-dog period is set to be 1024ms

          CSEG    AT      0
          JMP     XRESET           ; Reset vector

          ORG     100H

XRESET:   ORL     WMCON,#PERIOD    ; Define Watch-dog period
          ORL     WMCON,#WDTEN     ; Watch-dog timer is enabled

          MOV     A,R3             ; R3 is moved to port 1
          MOV     P1,A
          INC     R3               ; Register R3 is incremented by 1

LAB:      SJMP    LAB              ; Wait for watch-dog reset

          END                      ; End of program


Post a Comment

If you have any questions or droughts feel free to ask here.