So here is the Code for Blinking LEDs for finite times.
The concept of finite loop is used here. Let us see how to form such a loop in Assembly.
MOV R6, #8 //R6 value should be = Loop count
AGAIN: MOV P2, #11111111B //Turn On all the LEDs
ACALL DELAY //ADD Delay
MOV P2, #00000000B //Turn Off all the LEDs
ACALL DELAY //ADD Delay again
DJNZ R6, X1 //
HERE:SJMP HERE //To stop blinking after 8 times
DELAY: //Program for delay
MOV R1, #10
MOV R2, #10
MOV R3, #2
LOOP1: DJNZ R3, LOOP1
DJNZ R2, Y2
DJNZ R1, Y3
RET
END
The concept of finite loop is used here. Let us see how to form such a loop in Assembly.
![]() |
MOV R6, #8 //R6 value should be = Loop count
AGAIN: MOV P2, #11111111B //Turn On all the LEDs
ACALL DELAY //ADD Delay
MOV P2, #00000000B //Turn Off all the LEDs
ACALL DELAY //ADD Delay again
DJNZ R6, X1 //
HERE:SJMP HERE //To stop blinking after 8 times
DELAY: //Program for delay
MOV R1, #10
MOV R2, #10
MOV R3, #2
LOOP1: DJNZ R3, LOOP1
DJNZ R2, Y2
DJNZ R1, Y3
RET
END

No comments:
Post a Comment