Friday, June 18, 2010

LED Test Example



















In this example i m trying to describe the basic components which have been attached to 89c51 microcontroller to make it run in normal mode.
And also in this example i Blink LED.
Following is the sample program to blink LED.

ORG 0H
AGAIN:
CLR P2.0                 ;SEND LOW SIGNAL TO PORT 2 BIT NO. 0
CALL DELAY         ;CALL DELAY SUBROUTINE
SETB P2.0               ;SEND HIGH SIGNAL TO PORT 2 BIT NO. 0
CALL DELAY         ;CALL DELAY SUBROUTINE
SJMP AGAIN         ;JUMP TO LABEL AGAIN

DELAY:
MOV R1,#255        ;MOVE 255 TO REGISTER R1
HERE:
MOV R2,#50          ;MOVE 50 TO REGISTER R1
DJNZ R2,$             ;DECREMENT IN R2 UNTILL IT BECOME ZERO
DJNZ R1,HERE     ;DECREMENT IN R1 UNTILL IT BECOME ZERO
RET                        ;RETURN TO LAST POSITION
END

No comments: