Lab#05
INTRODUCTION TO MICROCONTROLLER 8051, KEIL
SOFTWARE AND PROTEUS SOFTWARE
OBJECTIVE:
• Awareness to the ATMEL 8051 RIM Trainer Kit.
• Study the ATMEL 8051 data sheet.
• Familiarization with proteus software
• Simulation of microcontroller circuits using proteus
DISCUSSION:
Following is the summary of introduction to 8051 microcontroller and keil software
8051 Microcontroller:
• 8051 microcontroller is designed by Intel in 1981. It is an 8-bit microcontroller. It is built
with 40 pins DIP (dual inline package), 4kb of ROM storage and 128 bytes of RAM
storage, 2 16-bit timers.
• It consists of are four parallel 8-bit ports, which are programmable as well as addressable
as per the requirement.
• An on-chip crystal oscillator is integrated in the microcontroller having crystal frequency
of 12 MHz.
• Its foundation was on Harvard Architecture and was developed principally for bringing
into play in Embedded Systems.
• It also consists of 8 bit B register as majorly functioning blocks and 8051 microcontroller
programming is done with embedded C language using Keil software. It also has several
other 8 bit and 16-bit registers.
• Four I/O ports (8-bit wide each)
• Two 16-bit Timers(T0,T1)
• 1-Serial Port (UART)
• 6-Interrupt Sources
8051 Microcontroller Pin Configuration
KEIL Software:
Keil development tools for the 8051 Microcontroller Architecture support every level of
software developer from the professional applications engineer to the student just learning about
embedded software development.
Steps to use the software:
1. Open the Keil software.
2. Click the project on the main tool bar.
3. Select new project and name it.
4. Then select Atmel 89C51 microcontroller.
5. Create a new file from the file menu.
6. Save the file with extension with .asm or .c.
7. Click the target in the main window, and then right click the source to select the saved
1. file.
8. Now open a new file and type the program, save it with a new name.
9. Right click the target and go to its properties.
10. Change the microcontroller frequency to 11.0592 MHz.
11. On the output menu, check the “Create HEX file” box.
LAB TASKS
Task#01
Simulation of 8051 Microcontroller using PROTEUS
Proteus circuit
Learning Outcomes
The lab achieved the following learning outcomes:
• We got introduced to 8051 Microcontroller
• Studied the ATMEL 8051 data sheet.
• Learned how to simulate 8051 microcontroller circuits using proteus
• Was introduced to KEIL software
• Studied assembly language
Lab#06
GENERATING DIFFERENT PATTERNS ON LED’s
OBJECTIVE:
1. Using microcontroller ports as output
2. Getting introduced to smart-pro 5000u burner and it’s software used to program
3. microcontroller using smart-pro 5000u burner
4. Sending data bytes on data ports of microcontroller
5. Getting introduced to machine cycle and learning to generate desired delay
6. Generating different patterns and displaying the outputs on LEDs
DISCUSSION:
Following is the summary of coding with assembly language using KEIL software:
Assembly Programming:
In computer programming, assembly language often abbreviated asm, is any low-level
programming language in which there is a very strong correspondence between the instructions in
the language and the architecture's machine code instructions. Because assembly depends on the
machine code instructions, every assembler has its own assembly language which is designed for
exactly one specific computer architecture.
A processor understands only machine language instructions, which are strings of 1's and 0's.
However, machine language is too obscure and complex for using in software development. So,
the low-level assembly language is designed for a specific family of processors that represents
various instructions in symbolic code and a more understandable form.
As in figure different types of low level languages and high level languages are shown
How Assembly Language works
Introduction to Assembly Language:
An assembly language instruction consists of four fields
Label:
The label is used when you have to jump from any specific location of code to a specific
command so you have to name that command using label.
Mnemonic:
Mnemonic is used for opcode of command like add, mov.
Operands:
Operands are used to mention the registers or constants used by command.
Comment:
Comment field is used to make the code user friendly.
DIRECTIVES:
ORG and END are directives to the assembler. ORG tells the assembler to place the opcode at
memory location 0 and END indicates to the Assembler the end of source code. ORG should be
used because it sets the origin at 0 and it is necessary to set the origin at 0 because on power ON
the contents of PC are at 0, so it expects the start of code to be at zero.
MOV INSTRUCTION:
MOV instruction simply copies the data from one location into another. It has the following
format
Mov A,#0F2h
Mov A,#11110010b
Mov A,#242
Rotate Right and Rotate Left
LAB TASKS
Task#01
Code to blink even and odd LEDs one after the other
Program Code
org 00h
MOV A,#10101010b //moving value in a register
MOV B,#01010101b
repeat: //adding label
MOV p2,A //moving value to port
call delay //calling label
MOV p2,B
call delay
jmp repeat
delay:
MOV r6,#230
label2:
MOV r7,#250
label1:
sqqqqqqqqqdjnz r7,label1 //loop to call delay it will run for 230x250 times
djnz r6,label2
ret
end
Question No.1
Proteus circuit
Task#02
Code to blink 8 LEDs in sequence one after the other using setb and clr
instruction.
Program Code
org 00h
repeat:
clr p2.0
clr p2.1
clr p2.2
clr p2.3
clr p2.4
clr p2.5
clr p2.6
setb p2.7
call delay
call delay
call delay
setb p2.6
call delay
call delay
call delay
setb p2.5
call delay
call delay
call delay
setb p2.4
call delay
call delay
call delay
setb p2.3
call delay
call delay
call delay
setb p2.2
call delay
call delay
call delay
setb p2.1
call delay
call delay
call delay
setb p2.0
call delay
call delay
call delay
jmp repeat
delay:
mov r6,#230
label1:
mov r7,#250
label2:
djnz r7,label2 //loop to call delay
djnz r6,label1
ret
end
Proteus circuit
Task#03
code to blink LED with 5 seconds delay.
Program Code
org 00h
repeat: //adding label
mov A,#11111111b
mov B,#00000000b //moving value in a rigester
mov p2,A //moving value to port
call delay
mov p2,B //moving value to port
call delay
jmp repeat
delay:
mov r3,#40
L3:
mov r4,230
L2:
mov r5,250
L1:
djnz r5,L1
djnz r4,L2
djnz r3,l3
ret
end
Calculations
Proteus circuit
Task#04
Coding the following sequences on LEDs
• Blinking LEDs towards right
• Blinking LEDs towards left
Program Code
org 00h
mov A,#00000001b
mov p2,A
repeatLEFT:
call delay
rl A
mov p2,A
mov r5,#7
djnz r5,repeatLEFT
mov A,#00000001b
mov p2,A
repeatRIGHT: //moving value to port
call delay
call delay
rr A //calling label
mov p2,A
call delay
mov r4,#7
djnz r4,repeatRIGHT
delay:
mov r6,#230
label1:
mov r7,#250
label2:
djnz r7,label2 //loop to call delay it will run for times
djnz r6,label1
ret
end
Proteus circuit
Learning Outcomes
The lab achieved the following learning outcomes:
• Learned to use 8051 microcontroller ports as output
• Was introduced to assembly language programming on KEIL software
• Simulated the written code on Proteus to see real time hardware results
• Learned how to send data bytes on data ports of microcontroller
• Got introduced to machine cycle and learning to generate desired delay
• Generated different patterns and displaying the outputs on LEDs by using
KEIL and PROTEUS