SlideShare a Scribd company logo
SRI G PULLA REDDY GOVT. POLYTECHNIC,
KURNOOL
Affiliated to STATE BOARD OF TECHNICAL EDUCATION &TRAINING, A.P .
Certified that this is the bonafied record of the work done by
Mr./Miss ______________________________________________________
of__________Diploma in __________________________________________
laboratory
Date: _________ Staff-in-charge
Head of the Department
PIN: _____________________
Submitted for the practical examination held on _________________________
Internal Examiner External Examiner _________________________________
External Examiner External Examiner _________________________________
INDEX
S.NO NAME OF THE EXPERIMENT DATE SIGNATURE
1
2
3
4
5
6
7
8
9
Experiment-1
Aim: To understand the 8051 programming environment in Edsim51 simulator and study
the circuit schematic.
Tools:
1. PC with OS Windows 7 or later.
2. Java Runtime Environment.
3. Edsim51-di(dynamic interface) simulator.
Results:
1. Edsim51-di simulator successfully installed.
2. Got accustomed to Edsim51-di interface.
3. Written an 8051 assembly language program, assembled and successfully executed.
4. Got accustomed to peripherals and their connections to 8051 in Edsim51-di.
Edsim51-di user interface and circuit schematic suitable for wire- wrapping is as
below:
micro controllers lecture notes unit 1 and 2
Experiment-2
Aim: To experiment with 8051 instruction set covering addressing modes, arithmetic
instructions by performing addition of two 16-bit numbers
Tools:
1. Edsim51-di(dynamic interface) simulator.
Program:
ORG 0000H
MOV 21H, #0CDH ; Low byte of 1st 16-bit number
MOV 20H, #0ABH ; High byte of 1st 16-bit number
MOV 31H, #034H ; Low byte of 1st 16-bit number
MOV 30H, #012H ; High byte of 1st 16-bit number
;Above instructions used direct and immediate addressing
;modes
;Addition procedure
CLR CY
MOV A, 21H
ADD A, 31H
MOV 41H, A ;Move low byte of result into memory location
MOV A, 20H
ADDC A, 30H
MOV 40H, A ; Move high byte of result into memory location
;Final 16 bit answer in [CY][40H][41H]
END
Results:
Experiment-3
Aim: To experiment with 8051 instruction set covering addressing modes, arithmetic,
logical, jump and loop instructions by writing an 8051 assembly language program which
initialises all RAM locations to value ‘0’
Tools:
1. Edsim51-di(dynamic interface) simulator.
Program:
ORG 0000H
MOV R0,#126 ;R0 for storing count - 126 for all 128 minus
;2 locations
MOV R1,#02 ;R1 holds memory locations address and
;initialised to location 02H
LOOP:
MOV @R1,#00H ;Mov 00H into location pointed by R1
INC R1 ;Point to next memory location
DJNZ R0,LOOP ;Loop until count is 0
MOV 01H,#00H
MOV 00H,#00H
END
Results:
Experiment-4
Aim: To experiment with 8051 instruction set covering addressing modes, arithmetic,
logical, jump and loop instructions and also covers a method to access i/o port of 8051 by
writing an 8051 assembly language program which checks if a given number is prime or not.
If the given number is prime the program glows up an LED and if it’s not a prime then two
LED are glown. [Circuit schematic is as given in Experiment-1].
Tools:
1. Edsim51-di(dynamic interface) simulator.
Program:
ORG 0000H
MOV R0,#138 ;Given number is in register R0
MOV A,R0 ;
SUBB A,#2 ;Number of divisions to perform
MOV R1,A
CLR P1.0 ;Assume given number prime by lighting up an LED
MOV R2,#2 ;Start with number 2 as divisor
LOOP:
MOV A,R0 ;Mov dividend into A
MOV B,R2 ;Mov divisor into B
DIV AB ;Divide Dividend with divisor
MOV A,B ;Copy remainder into ACC
JZ NOTPRIME ;If not prime jump to code to light up
;another LED
INC R2
DJNZ R1,LOOP ;Decrement number of remaining
;divisions
SJMP ENDM ;Jump to end of program
NOTPRIME:
CLR P1.1
ENDM:
END
Results:
Experiment-5
Aim: To experiment with 8051 instruction set covering addressing modes, data transfer,
arithmetic, logical, jump and loop instructions by writing an 8051 assembly language
program to copy block of contents from code memory(ROM) to data memory(RAM).
Tools:
1. Edsim51-di(dynamic interface) simulator.
Program:
ORG 0000H
0000| LJMP CODE ;Instruction to jump to code
ORG 0003H ;Starting address of block of contents in
;ROM
DB "THIS CONTENT IN ROM IS COPIED TO RAM"
CODE:
0027| MOV R0,#36 ;Number of bytes to be copied in R0
0029| MOV R1,#20H ;Destination RAM address starting
002B| MOV R2,#00H ;Source index address
002D| MOV DPTR,#0003H ;Starting address of block of data
0030| MOV A,#00H ;Use ACC as index
LOOP:
0032| MOV A,R2
0033| MOVC A,@A+DPTR
0034| MOV @R1,A
0035| INC R1
0036| INC R2
0037| DJNZ R0,LOOP
END
Results:
Experiment-6
Aim: To experiment with 8051 instruction set covering addressing modes, data transfer,
arithmetic, logical, jump and loop instructions by writing an 8051 assembly language
program to find sum of first ‘n’ natural number where n is given in a register (limited to 8-bit
only).
Tools:
1. Edsim51-di(dynamic interface) simulator.
Program:
ORG 0000H
0000| MOV R0,#10 ;Given number
0002| MOV A,#00H ;ACC stores temporary results
LOOP:
0004| ADD A,R0 ;Add R0 to temporary Sum
0005| DJNZ R0,LOOP ;Decrement R0 and iterate again if
;not zero
;Final answer in ACC
END
Results:
Experiment-7
Aim: To experiment with 8051 instruction set covering configuration of inbuilt
timers/counters, interrupts, I/O operations, bit wise instructions by writing an 8051
assembly language program to blink an LED by generating a time delay using internal timer
and software interrupt.
Tools:
1. Edsim51-di(dynamic interface) simulator.
Note: Simulation results can be best viewed when system clock frequency is set to 12.0
MHz and screen update frequency is set to 50000 in the Edsim51-di control panel
settings.
Program:
ORG 000BH ;TIMER0 overflow interrupt vector address
000B| CPL P1.0 ;Very small ISR to update LED status
;Jump to another location if ISR code is
;not sufficiently small
000D| RETI ;Return from ISR
ORG 0000H ;8051 PC value on RESET/POWER ON
0000| LJMP 0050H ;JUMP to main program
ORG 0050H ;Main program code begins here
0050| MOV TMOD,#51H ;To configure TIMER0 in 16 bit timer
;mode
0053| SETB TCON.4 ;Start the timer
0055| MOV IE,#82H ;Enable Timer0 S/W interupt
END
Results:
Experiment-8
Aim: To experiment with 8051 instruction set covering all categories of instructions by
writing an 8051 assembly language program to read key presses into register B
Tools:
1. Edsim51-di(dynamic interface) simulator.
Note: Circuit schematic is as in Experiment-1
Program:
org 0000h
readkey:
clr f0 ;Flag to indicate if a key is pressed
mov p0,#6Fh ;Assume key in col0 is pressed
acall scanrows ;Scan each row and set flag if
;key in particular row is pressed
jb f0,col0 ;flag set indicates key in col0 is
;pressed
mov p0,#5Fh ;Assume key in col0 is pressed
acall scanrows
jb f0,col1 ;flag set indicates key in col0 is
;pressed
mov p0,#3Fh
acall scanrows
jb f0,col2
ljmp readkey ;Repeat row scanning continuously
col0:
mov B,r0 ;Key press is copied into B register
ljmp endm
col1:
dec r0
mov B,r0
ljmp endm
col2:
dec r0
dec r0
mov B,r0
endm:
ljmp readkey ;to read multiple keys
ljmp endx ;to halt after reading one key
scanrows:
jnb p0.0,row0 ;bottom row
jnb p0.1,row1 ;row 1 from bottom
jnb p0.2,row2
jnb p0.3,row3
ret
row0: ;code to copy corresponding key
;to reg r0
mov r0,#0Ch
setb f0
ljmp endp
row1:
mov r0,#09h
setb f0
ljmp endp
row2:
mov r0,#06h
setb f0
ljmp endp
row3:
mov r0,#03h
setb f0
ljmp endp
endp:
ret
endx:
end
Results:
Experiment-9
Aim: To experiment with 8051 instruction set covering all categories of instructions by
writing an 8051 assembly language program to read key press display each key pressed in
connected 7-segment display.
Tools:
1. Edsim51-di(dynamic interface) simulator.
Note: Circuit schematic is as in Experiment-1
Program:
org 0000h
ljmp readkey
db C0h
db F9h
db A4h
db B0h
db 99h
db 92h
db 82h
db F8h
db 80h
db 90h ;Codes Stored in ROM for displaying character in
;7-Segment
readkey:
clr f0
mov p0,#0EFh
acall scanrows
jb f0,col0 ;right most
mov p0,#0DFh
acall scanrows
jb f0,col1
mov p0,#0BFh
acall scanrows
jb f0,col2
ljmp readkey
col0:
mov B,r0
lcall display
ljmp endm
col1:
dec r0
mov B,r0
mov a,b
cjne a,#0bh,hjump ;here jump
mov B,#00h
hjump:
lcall display
ljmp endm
col2:
dec r0
dec r0
mov B,r0
lcall display
endm:
ljmp readkey ;to read multiple keys
ljmp endx ;to halt after reading one key
scanrows:
jnb p0.0,row0 ;bottom row
jnb p0.1,row1
jnb p0.2,row2
jnb p0.3,row3
ret
row0:
mov r0,#0Ch
setb f0
ljmp endp
row1:
mov r0,#09h
setb f0
ljmp endp
row2:
mov r0,#06h
setb f0
ljmp endp
row3:
mov r0,#03h
setb f0
ljmp endp
endp:
ret
;following display routine fetches code from ROM and
;sends it port to which 7-segment display is connected
display:
mov dptr,#0003
mov a,b
movc a,@a+dptr
mov p1,a
ret
endx:
end
Results:

More Related Content

DOCX
MES LAB MANUAL for engineering students.
PDF
Mic practicals
PPTX
Micro task1
PPT
Microcontroller 8051- soft.ppt
PPT
Chp6 assembly language programming for pic copy
PPTX
Applications of microcontroller(8051)
PPTX
Basic programming of 8085
PDF
Https _doc-0o-c4-apps-viewer.googleusercontent
MES LAB MANUAL for engineering students.
Mic practicals
Micro task1
Microcontroller 8051- soft.ppt
Chp6 assembly language programming for pic copy
Applications of microcontroller(8051)
Basic programming of 8085
Https _doc-0o-c4-apps-viewer.googleusercontent

Similar to micro controllers lecture notes unit 1 and 2 (20)

PDF
5 addressing modes
PPTX
8051 microcontroller
PPT
Micro controller(pratheesh)
DOCX
Introduction to 8085 & it's description(includes basic lab experiments)
PDF
Gain Experience with GPIO, LED Interface and Functions in TI TIVA C Launchpad...
PPTX
8051 microcontroller
PPTX
PPTX
PPT
Addressing modes
PDF
Real Time Embedded System
PPT
12 mt06ped008
PDF
MPMC UNIT-2.pdf
TXT
New text document
PPTX
Stacks & subroutines 1
PDF
Lab manual mp
PDF
8085labmanual.pdf
PPT
Emb day2 8051
PPT
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
PPT
B.sc cs-ii-u-3.1-basic computer programming and micro programmed control
PPT
1347 Assembly Language Programming Of 8051
5 addressing modes
8051 microcontroller
Micro controller(pratheesh)
Introduction to 8085 & it's description(includes basic lab experiments)
Gain Experience with GPIO, LED Interface and Functions in TI TIVA C Launchpad...
8051 microcontroller
Addressing modes
Real Time Embedded System
12 mt06ped008
MPMC UNIT-2.pdf
New text document
Stacks & subroutines 1
Lab manual mp
8085labmanual.pdf
Emb day2 8051
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
B.sc cs-ii-u-3.1-basic computer programming and micro programmed control
1347 Assembly Language Programming Of 8051
Ad

Recently uploaded (20)

PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
web development for engineering and engineering
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
additive manufacturing of ss316l using mig welding
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
737-MAX_SRG.pdf student reference guides
PDF
composite construction of structures.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PPTX
Geodesy 1.pptx...............................................
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
DOCX
573137875-Attendance-Management-System-original
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
CH1 Production IntroductoryConcepts.pptx
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
web development for engineering and engineering
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
additive manufacturing of ss316l using mig welding
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
737-MAX_SRG.pdf student reference guides
composite construction of structures.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Foundation to blockchain - A guide to Blockchain Tech
Fundamentals of safety and accident prevention -final (1).pptx
Geodesy 1.pptx...............................................
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
573137875-Attendance-Management-System-original
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
bas. eng. economics group 4 presentation 1.pptx
Safety Seminar civil to be ensured for safe working.
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Ad

micro controllers lecture notes unit 1 and 2

  • 1. SRI G PULLA REDDY GOVT. POLYTECHNIC, KURNOOL Affiliated to STATE BOARD OF TECHNICAL EDUCATION &TRAINING, A.P . Certified that this is the bonafied record of the work done by Mr./Miss ______________________________________________________ of__________Diploma in __________________________________________ laboratory Date: _________ Staff-in-charge Head of the Department PIN: _____________________ Submitted for the practical examination held on _________________________ Internal Examiner External Examiner _________________________________ External Examiner External Examiner _________________________________
  • 2. INDEX S.NO NAME OF THE EXPERIMENT DATE SIGNATURE 1 2 3 4 5 6 7 8 9
  • 3. Experiment-1 Aim: To understand the 8051 programming environment in Edsim51 simulator and study the circuit schematic. Tools: 1. PC with OS Windows 7 or later. 2. Java Runtime Environment. 3. Edsim51-di(dynamic interface) simulator. Results: 1. Edsim51-di simulator successfully installed. 2. Got accustomed to Edsim51-di interface. 3. Written an 8051 assembly language program, assembled and successfully executed. 4. Got accustomed to peripherals and their connections to 8051 in Edsim51-di. Edsim51-di user interface and circuit schematic suitable for wire- wrapping is as below:
  • 5. Experiment-2 Aim: To experiment with 8051 instruction set covering addressing modes, arithmetic instructions by performing addition of two 16-bit numbers Tools: 1. Edsim51-di(dynamic interface) simulator. Program: ORG 0000H MOV 21H, #0CDH ; Low byte of 1st 16-bit number MOV 20H, #0ABH ; High byte of 1st 16-bit number MOV 31H, #034H ; Low byte of 1st 16-bit number MOV 30H, #012H ; High byte of 1st 16-bit number ;Above instructions used direct and immediate addressing ;modes ;Addition procedure CLR CY MOV A, 21H ADD A, 31H MOV 41H, A ;Move low byte of result into memory location MOV A, 20H ADDC A, 30H MOV 40H, A ; Move high byte of result into memory location ;Final 16 bit answer in [CY][40H][41H] END Results:
  • 6. Experiment-3 Aim: To experiment with 8051 instruction set covering addressing modes, arithmetic, logical, jump and loop instructions by writing an 8051 assembly language program which initialises all RAM locations to value ‘0’ Tools: 1. Edsim51-di(dynamic interface) simulator. Program: ORG 0000H MOV R0,#126 ;R0 for storing count - 126 for all 128 minus ;2 locations MOV R1,#02 ;R1 holds memory locations address and ;initialised to location 02H LOOP: MOV @R1,#00H ;Mov 00H into location pointed by R1 INC R1 ;Point to next memory location DJNZ R0,LOOP ;Loop until count is 0 MOV 01H,#00H MOV 00H,#00H END Results:
  • 7. Experiment-4 Aim: To experiment with 8051 instruction set covering addressing modes, arithmetic, logical, jump and loop instructions and also covers a method to access i/o port of 8051 by writing an 8051 assembly language program which checks if a given number is prime or not. If the given number is prime the program glows up an LED and if it’s not a prime then two LED are glown. [Circuit schematic is as given in Experiment-1]. Tools: 1. Edsim51-di(dynamic interface) simulator. Program: ORG 0000H MOV R0,#138 ;Given number is in register R0 MOV A,R0 ; SUBB A,#2 ;Number of divisions to perform MOV R1,A CLR P1.0 ;Assume given number prime by lighting up an LED MOV R2,#2 ;Start with number 2 as divisor LOOP: MOV A,R0 ;Mov dividend into A MOV B,R2 ;Mov divisor into B DIV AB ;Divide Dividend with divisor MOV A,B ;Copy remainder into ACC JZ NOTPRIME ;If not prime jump to code to light up ;another LED INC R2 DJNZ R1,LOOP ;Decrement number of remaining ;divisions SJMP ENDM ;Jump to end of program NOTPRIME: CLR P1.1 ENDM: END Results:
  • 8. Experiment-5 Aim: To experiment with 8051 instruction set covering addressing modes, data transfer, arithmetic, logical, jump and loop instructions by writing an 8051 assembly language program to copy block of contents from code memory(ROM) to data memory(RAM). Tools: 1. Edsim51-di(dynamic interface) simulator. Program: ORG 0000H 0000| LJMP CODE ;Instruction to jump to code ORG 0003H ;Starting address of block of contents in ;ROM DB "THIS CONTENT IN ROM IS COPIED TO RAM" CODE: 0027| MOV R0,#36 ;Number of bytes to be copied in R0 0029| MOV R1,#20H ;Destination RAM address starting 002B| MOV R2,#00H ;Source index address 002D| MOV DPTR,#0003H ;Starting address of block of data 0030| MOV A,#00H ;Use ACC as index LOOP: 0032| MOV A,R2 0033| MOVC A,@A+DPTR 0034| MOV @R1,A 0035| INC R1 0036| INC R2 0037| DJNZ R0,LOOP END Results:
  • 9. Experiment-6 Aim: To experiment with 8051 instruction set covering addressing modes, data transfer, arithmetic, logical, jump and loop instructions by writing an 8051 assembly language program to find sum of first ‘n’ natural number where n is given in a register (limited to 8-bit only). Tools: 1. Edsim51-di(dynamic interface) simulator. Program: ORG 0000H 0000| MOV R0,#10 ;Given number 0002| MOV A,#00H ;ACC stores temporary results LOOP: 0004| ADD A,R0 ;Add R0 to temporary Sum 0005| DJNZ R0,LOOP ;Decrement R0 and iterate again if ;not zero ;Final answer in ACC END Results:
  • 10. Experiment-7 Aim: To experiment with 8051 instruction set covering configuration of inbuilt timers/counters, interrupts, I/O operations, bit wise instructions by writing an 8051 assembly language program to blink an LED by generating a time delay using internal timer and software interrupt. Tools: 1. Edsim51-di(dynamic interface) simulator. Note: Simulation results can be best viewed when system clock frequency is set to 12.0 MHz and screen update frequency is set to 50000 in the Edsim51-di control panel settings. Program: ORG 000BH ;TIMER0 overflow interrupt vector address 000B| CPL P1.0 ;Very small ISR to update LED status ;Jump to another location if ISR code is ;not sufficiently small 000D| RETI ;Return from ISR ORG 0000H ;8051 PC value on RESET/POWER ON 0000| LJMP 0050H ;JUMP to main program ORG 0050H ;Main program code begins here 0050| MOV TMOD,#51H ;To configure TIMER0 in 16 bit timer ;mode 0053| SETB TCON.4 ;Start the timer 0055| MOV IE,#82H ;Enable Timer0 S/W interupt END Results:
  • 11. Experiment-8 Aim: To experiment with 8051 instruction set covering all categories of instructions by writing an 8051 assembly language program to read key presses into register B Tools: 1. Edsim51-di(dynamic interface) simulator. Note: Circuit schematic is as in Experiment-1 Program: org 0000h readkey: clr f0 ;Flag to indicate if a key is pressed mov p0,#6Fh ;Assume key in col0 is pressed acall scanrows ;Scan each row and set flag if ;key in particular row is pressed jb f0,col0 ;flag set indicates key in col0 is ;pressed mov p0,#5Fh ;Assume key in col0 is pressed acall scanrows jb f0,col1 ;flag set indicates key in col0 is ;pressed mov p0,#3Fh acall scanrows jb f0,col2 ljmp readkey ;Repeat row scanning continuously col0: mov B,r0 ;Key press is copied into B register ljmp endm col1: dec r0 mov B,r0 ljmp endm col2: dec r0 dec r0 mov B,r0 endm: ljmp readkey ;to read multiple keys ljmp endx ;to halt after reading one key
  • 12. scanrows: jnb p0.0,row0 ;bottom row jnb p0.1,row1 ;row 1 from bottom jnb p0.2,row2 jnb p0.3,row3 ret row0: ;code to copy corresponding key ;to reg r0 mov r0,#0Ch setb f0 ljmp endp row1: mov r0,#09h setb f0 ljmp endp row2: mov r0,#06h setb f0 ljmp endp row3: mov r0,#03h setb f0 ljmp endp endp: ret endx: end Results:
  • 13. Experiment-9 Aim: To experiment with 8051 instruction set covering all categories of instructions by writing an 8051 assembly language program to read key press display each key pressed in connected 7-segment display. Tools: 1. Edsim51-di(dynamic interface) simulator. Note: Circuit schematic is as in Experiment-1 Program: org 0000h ljmp readkey db C0h db F9h db A4h db B0h db 99h db 92h db 82h db F8h db 80h db 90h ;Codes Stored in ROM for displaying character in ;7-Segment readkey: clr f0 mov p0,#0EFh acall scanrows jb f0,col0 ;right most mov p0,#0DFh acall scanrows jb f0,col1 mov p0,#0BFh acall scanrows jb f0,col2 ljmp readkey col0: mov B,r0 lcall display ljmp endm col1:
  • 14. dec r0 mov B,r0 mov a,b cjne a,#0bh,hjump ;here jump mov B,#00h hjump: lcall display ljmp endm col2: dec r0 dec r0 mov B,r0 lcall display endm: ljmp readkey ;to read multiple keys ljmp endx ;to halt after reading one key scanrows: jnb p0.0,row0 ;bottom row jnb p0.1,row1 jnb p0.2,row2 jnb p0.3,row3 ret row0: mov r0,#0Ch setb f0 ljmp endp row1: mov r0,#09h setb f0 ljmp endp row2: mov r0,#06h setb f0 ljmp endp row3: mov r0,#03h setb f0 ljmp endp endp: ret ;following display routine fetches code from ROM and ;sends it port to which 7-segment display is connected
  • 15. display: mov dptr,#0003 mov a,b movc a,@a+dptr mov p1,a ret endx: end Results: