Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views5 pages

Microcontroller and Interfacing Lab 7 final

it is a lab experitment of mci in engg clg

Uploaded by

Amaan Mohammed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

Microcontroller and Interfacing Lab 7 final

it is a lab experitment of mci in engg clg

Uploaded by

Amaan Mohammed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Date: Padre Conceicao College of Engineering Page no:

MICROCONTROLLER AND INTERFACING


LAB 7: LED Blinking on Development board

Aim: Implement LED blinking on the 8051 development board.


Theory:

● Implement the given program on the development board and


explain the codes working.
ORG 00H :Set the origin of the code at address 00H
LJMP START :Jump to the START label to begin execution
DELAY: :Start of the delay subroutine
MOV R3,#0x02 :Load the value 0x02 into register R3 (counter)
MOV R4,#0x0 :Load the value 0x00 into register R4 (counter)
MOV R5,#0x0 :Load the value 0x00 into register R5 (counter)
LOOP1: :Start of the first delay loop
DJNZ R5, LOOP1 :Decrement R5 and jump back to LOOP1 if not
zero
R4, LOOP1 :Decrement R4 and jump back to LOOP1 if not zero
DJNZ R3, LOOP1 :Decrement R3 and jump back to LOOP1 if not
zero
RET :Return from the delay subroutine
START: :Start of the main program at the START label
MOV R1,#00H :Load the value 0x00 into register
R1 LOOP2: :Start of the main loop
Date: Padre Conceicao College of Engineering Page no:

MOV P2,R1 :Move the value of R1 to Port 2 (controls LEDs)


INC R1 :Increment the value of R1
ACALL DELAY :Call the delay subroutine
SJMP LOOP2 :Unconditional jump back to LOOP2 for
continuous looping END

● Create your own program for the 8051 microcontroller that will
move a single LED light from left to right and then back from right
to left on an array of 8 LEDs connected to port 2 of the
microcontroller.
ORG 00H //Set the origin of the code at address 00H
LJMP START //Jump to the START label to begin execution
DELAY: // Start of the delay subroutine
MOV R3,#0x02 //Load the value 0x02 into register R3 (counter)
MOV R4,#0x0 //Load the value 0x00 into register R4 (counter)
MOV R5,#0x0 //Load the value 0x00 into register R5 (counter)
LOOP1: //Start of the first delay loop
DJNZ R5, LOOP1 //Decrement R5 and jump back to LOOP1 if not zero
DJNZ R4, LOOP1 //Decrement R4 and jump back to LOOP1 if not zero
DJNZ R3, LOOP1 //Decrement R3 and jump back to LOOP1 if not zero
RET //Return from the delay subroutine
START: //Start of the main program at the START label
MOV A,#0FFH //Load the value 0x00 into register R1
LOOP2: //Start of the main loop
ACALL DELAY
MOV P2,A //Move the value of R1 to Port 2 (controls LEDs)
RLC A //Increment the value of R1
JC LOOP2
LOOP3:
ACALL DELAY //Call the delay subroutine
MOV P2,A
RRC A
JC LOOP3
Date: Padre Conceicao College of Engineering Page no:

SJMP LOOP2 //Unconditional jump back to LOOP2 for continuous


looping
END

Procedure:
1. Open Keil.
2. Open new Keil project.
3. Save the project in your folder.
4. Choose AT89C51 as µcontroller.
5. Make a new file.
6. Save the new file in your own folder with the extension .asm.
7. Write your code in the new file build code.
8. If there are no errors, go to Debug and then Run the code.
9. Convert the .asm file into .hex file.
10. Upload the .hex file in the microcontroller.
Date: Padre Conceicao College of Engineering Page no:

Solution:

Fig 1.1: Code for LED Blinking Fig 1.2: Code for LED Blinking
Date: Padre Conceicao College of Engineering Page no:

Fig 1.3: Output

Conclusion: The implementation of the LED blink code on the 8051


development board was achieved.

You might also like