;********************************************************************
;
; Author        : ADI - Apps            www.analog.com/MicroConverter
;
; Date          : October 2003
;
; File          : blink.asm
;
; Hardware      : ADuC842/ADuC843
;
; Description   : Blinks LED continuously.
;                 200mSec period @ 50% duty cycle.
;
;********************************************************************

$MOD842                         ; use 8052 predefined symbols

LED     EQU     P3.4            ; P3.4 is red LED on eval board

;____________________________________________________________________
                                                       ; MAIN PROGRAM
CSEG

ORG  0000h

	MOV	A,#010
BLINK: 	CPL     LED             ; flash (complement) the red LED
        CALL    DELAY           ; call software delay
        JMP     BLINK           ; repeat indefinately

;____________________________________________________________________
                                                        ; SUBROUTINES
DELAY:					; Delays by ms 10* A
					; 10mSec based on 2.094MHZ 
					; Core Clock 
					; i.e. default ADuC842 Clock

		MOV	R1,A		; Acc holds delay variable (1 clock)
 DLY0:		MOV	R2,#01Bh	; Set up delay loop0 (2 clocks)
 DLY1:		MOV	R3,#0FFh	; Set up delay loop1 (2 clocks)
		DJNZ	R3,$		; Dec R3 & Jump here until R3 is 0 (3 clocks)
		DJNZ	R2,DLY1         ; Dec R2 & Jump DLY1 until R2 is 0 (3 clocks)
		DJNZ	R1,DLY0		; Dec R1 & Jump DLY0 until R1 is 0 (3 clocks)
		RET			; Return from subroutine
;____________________________________________________________________

END
