SlideShare a Scribd company logo
1 of 18
GENERATE PATTERNS ON LED USING 8051
Objectives of the Lab
 Interfacing LEDs using 8051 ports as output ports.
 Generating Delay using Delay Subroutine.
 Checking Working of Code on Proteus.
 Programming 8051 using Smart-PRO Burner.
Deciding Pins or Ports to use
Use with
caution
If EA high,
P0 & P2 are
simple ports
otherwise
address bits
*We can use any
port, for now we
will use P2.
Introduction to Assembly in 8051
 An assembly language instruction consists of four fields.
[Label:] mnemonic [operands] [;comments]
 Label is used to jump to a specific code location from any
other location.
 Mnemonic is used for opcode of command e.g. add, mov.
 Operands are used to mention the registers or constants
used by command.
 Comment field is used to make the code user friendly.
 Square brackets show that these fields are optional.
Review
Registers (Naming) Normally Used
Accumulator (A or ACC) Base (B)
Ports (P0,P1,P2,P3 & Px.y) PSW (For Flags & Register Banks)
R0,R1,…,R7 SP(Stack Pointer)
DPTR(Data Pointer) Timer Registers
Serial Port Registers Interrupt Registers
PCON (Power Control
Register)
IP (Instruction Pointer)
Legend:
* Frequently used
* Special Functions
* Occasionally
* Used automatically
Instructions used in this Lab
 MOV DEST,SOURCE
 mov p0,#10101001b
 mov p0,#0A9h
 mov p0,#169d or mov p0,#169
 JMP LABEL
 DJNZ REG,LABEL
 RL A
 RR A
 See instruction set for the details of above commands.
Algorithm to generate LED
patterns
Start
Send seq to
output
First Sequence
Next Sequence
Call Delay
*Controller Programs tend to run forever i.e. in the infinite loop.
mov a,#seq
mov p2,a
rr a
call delay
Review
Program Structure (Directives)
org 00h
.
.
.
call delay
.
.
.
delay: ;subroutine
.
.
.
ret
end
Delay subroutine:
delay:
mov r6,#2
dl1:
mov r7,#10
dl2: djnz r7,dl2 ; djnz r7,$
djnz r6,dl1
ret
Delay Calculation
delay:
mov r6,#x
dl1:
mov r7,#y
djnz r7,$
djnz r6,dl1
ret
1
1
2 * y * x
2
2
*Refer to instruction set for delays of individual commands
Delay= (2y+1+2)x+1+2 =(2y+3)x+3 machine cycles
 Putting in the values of x and y, we can calculate delay
in machine cycles and then we can calculate the time
by multiplying this by the time one machine cycle takes.
Generating Required Delay
1. We discussed that the above subroutine creates delay of (2y+3)x+3
machine cycles. To convert this delay into time, we need to replace
machine cycle by the time it takes.
2. For a 12 MHz crystal, 1mc = 1µs, and delay=(2y+3)x+3µs.
3. If we want to create delay of 100 milli-seconds, then
100ms=(2y+3)x+3µs, one equation, two unknown, assume some value
of ‘y’ and find out ‘x’.
4. If the above calculated values of ‘x’ and ‘y’ are used, one will be able to
generate delay of 100 ms, using a 12 MHz crystal.
*Calculate values of x and y for generating delay of 100 ms with XTAL=11.0592 MHz
Using Proteus to simulate 8051
codes
1. The ‘HEX’ file generated by ‘keil’ or any other software as such can be
used to check the working of code on software using proteus.
2. Just search for ‘AT89c51’, place the controller, double click on it to edit
properties
1. Change the clock frequency to 11.0592 MHz.
2. Click the ‘folder icon’ in front of Program files and locate the code hex
file.
3. In advanced properties, select ‘Simulate Program Fetches’ and ‘Yes’.
3. Then, place other devices, interconnect with 8051 and simply play the
simulation.
How to program a µC using
SmartPro 2008 (Programmer)
1. Connect your SmartPro 2008 Programmer to PC via
USB port and turn the device on using its adapter. Also,
place the µC carefully in the ZIF socket.
2. Locate and click ‘SmartPro 2008’ icon available on
desktop.
3. If it asks for the Programmer Select ‘Smart PRO 5000u’
and click demo.
*One must check, how to place different types of controller in the programmer.
How to program a µC using
SmartPro 2008 (Programmer)
4. Click ‘Select Device’ on the window or choose Device>Select or
press Ctrl+S.
1. In ‘Type’, select ‘MCU’
2. In ‘Manufacturer’, select ‘ATMEL’ , AT89Cxx.
3. In ‘Device’, select AT8951.
5. Now, select File>Open or press Ctrl+O, in ‘files of type’ select Intel
Hex and locate the ‘HEX’ file you want to program. Also, see if
buffer is loaded with the new ‘HEX’ file.
How to program a µC using
SmartPro 2008 (Programmer)
6. Now, there are a bunch of options that can be performed depending upon
the users needs.
1. F4 or Click ‘Read’: Reads a previous program already burned in the µC.
2. F5 or ‘Erase’: Erases the previous program in µC.
3. F6 or ‘Blank Check’: Verification if program is erased.
4. F7 or ‘Program’: Loads the *current HEX file in µC.
5. F8 or ‘Verify’: Verification if the program is properly loaded.
6. ‘Batch’: This option is used in Industry.
7. Spacebar or ‘Auto’: Performs all the steps from 2 to 5 in sequence.
7. Shortcut: Open SmartPro, slect device, locate hex file & press spacebar.
Debugging with µC
1. Unlike electronic circuits, the debugging with µC is different.
Firstly, there is software debugging and then there is hardware
debugging.
2. The software debugging includes the working of code.
3. The hardware debugging includes the working of code on
hardware and the devices interfaced.
4. Always perform µC experiment in three stages, test the µC IC and
generic board using led blinking, then verify the working of code
on Proteus software, then finally test the program on hardware.
Proteus Devices needed in this Lab
1. AT89c51
2. LED Bargraph
3. Resistor Pack
Lab Tasks
 Blink LED’s in different patterns with delay of 100
milli-seconds.
 Pattern 1: Blink LEDs towards right.
 Pattern 2: Blink LEDs towards left.
 Pattern 3: Blink even LEDs only.
 Pattern 4: Blink LEDs in the sequence
10000001,01000010,00100100,00011000.

More Related Content

What's hot

8 bit single cycle processor
8 bit single cycle processor8 bit single cycle processor
8 bit single cycle processorDhaval Kaneria
 
8051 programming skills using EMBEDDED C
8051 programming skills using EMBEDDED C8051 programming skills using EMBEDDED C
8051 programming skills using EMBEDDED CAman Sharma
 
Calculator design with lcd using fpga
Calculator design with lcd using fpgaCalculator design with lcd using fpga
Calculator design with lcd using fpgaHossam Hassan
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -evechiportal
 
Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Rodrigo Almeida
 
Writing c code for the 8051
Writing c code for the 8051Writing c code for the 8051
Writing c code for the 8051Quản Minh Tú
 
Embedded systems development Defcon 19
Embedded systems development Defcon 19Embedded systems development Defcon 19
Embedded systems development Defcon 19Rodrigo Almeida
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollerJhemi22
 
Ins and Outs of GPIO Programming
Ins and Outs of GPIO ProgrammingIns and Outs of GPIO Programming
Ins and Outs of GPIO ProgrammingICS
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manualtwinkleratna
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 MicrocontrollerAvijeet Negel
 

What's hot (20)

8 bit single cycle processor
8 bit single cycle processor8 bit single cycle processor
8 bit single cycle processor
 
8051 programming skills using EMBEDDED C
8051 programming skills using EMBEDDED C8051 programming skills using EMBEDDED C
8051 programming skills using EMBEDDED C
 
Microcontroller part 2
Microcontroller part 2Microcontroller part 2
Microcontroller part 2
 
Calculator design with lcd using fpga
Calculator design with lcd using fpgaCalculator design with lcd using fpga
Calculator design with lcd using fpga
 
89c5131datasheet
89c5131datasheet89c5131datasheet
89c5131datasheet
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eve
 
Lab3 s2
Lab3 s2Lab3 s2
Lab3 s2
 
Verilog lab mauual
Verilog lab mauualVerilog lab mauual
Verilog lab mauual
 
Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015Embedded systems design @ defcon 2015
Embedded systems design @ defcon 2015
 
Writing c code for the 8051
Writing c code for the 8051Writing c code for the 8051
Writing c code for the 8051
 
Embedded systems development Defcon 19
Embedded systems development Defcon 19Embedded systems development Defcon 19
Embedded systems development Defcon 19
 
W10: Interrupts
W10: InterruptsW10: Interrupts
W10: Interrupts
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Ins and Outs of GPIO Programming
Ins and Outs of GPIO ProgrammingIns and Outs of GPIO Programming
Ins and Outs of GPIO Programming
 
Fpga creating counter with internal clock
Fpga   creating counter with internal clockFpga   creating counter with internal clock
Fpga creating counter with internal clock
 
Embedded system - introduction to arm7
Embedded system -  introduction to arm7Embedded system -  introduction to arm7
Embedded system - introduction to arm7
 
Np unit iv i
Np unit iv iNp unit iv i
Np unit iv i
 
Microcontroller 8051 basics (part I)
Microcontroller 8051 basics (part I)Microcontroller 8051 basics (part I)
Microcontroller 8051 basics (part I)
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manual
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontroller
 

Viewers also liked

Digital to Analog Converter by LDCE students
Digital to Analog Converter by LDCE studentsDigital to Analog Converter by LDCE students
Digital to Analog Converter by LDCE studentsMitul Lakhani
 
Human Resource Management in a Sugar Factory.
Human Resource Management in a Sugar Factory.Human Resource Management in a Sugar Factory.
Human Resource Management in a Sugar Factory.Bikash S.
 
PSLV - C37 Cartosat -2 Series Satellite
PSLV - C37 Cartosat -2 Series SatellitePSLV - C37 Cartosat -2 Series Satellite
PSLV - C37 Cartosat -2 Series SatelliteBikash S.
 
ISRO (By Kalyanam Kiran)
ISRO (By Kalyanam Kiran)ISRO (By Kalyanam Kiran)
ISRO (By Kalyanam Kiran)Kalyanam Kiran
 
Microcontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingMicrocontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingAnkur Mahajan
 
ISRO Presentation
ISRO Presentation  ISRO Presentation
ISRO Presentation ashu chauhan
 

Viewers also liked (8)

Digital to Analog Converter by LDCE students
Digital to Analog Converter by LDCE studentsDigital to Analog Converter by LDCE students
Digital to Analog Converter by LDCE students
 
Mcu51
Mcu51Mcu51
Mcu51
 
Human Resource Management in a Sugar Factory.
Human Resource Management in a Sugar Factory.Human Resource Management in a Sugar Factory.
Human Resource Management in a Sugar Factory.
 
8051 i/o port circuit
8051 i/o port circuit8051 i/o port circuit
8051 i/o port circuit
 
PSLV - C37 Cartosat -2 Series Satellite
PSLV - C37 Cartosat -2 Series SatellitePSLV - C37 Cartosat -2 Series Satellite
PSLV - C37 Cartosat -2 Series Satellite
 
ISRO (By Kalyanam Kiran)
ISRO (By Kalyanam Kiran)ISRO (By Kalyanam Kiran)
ISRO (By Kalyanam Kiran)
 
Microcontroller 8051 and its interfacing
Microcontroller 8051 and its interfacingMicrocontroller 8051 and its interfacing
Microcontroller 8051 and its interfacing
 
ISRO Presentation
ISRO Presentation  ISRO Presentation
ISRO Presentation
 

Similar to Micro c lab2(led patterns)

20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Jorisimec.archive
 
Lab 1 reference manual
Lab 1 reference manualLab 1 reference manual
Lab 1 reference manualtrayyoo
 
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docxfelicidaddinwoodie
 
Digital Alarm Clock 446 project report
Digital Alarm Clock 446 project reportDigital Alarm Clock 446 project report
Digital Alarm Clock 446 project reportAkash Mhankale
 
Rodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationRodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationFelipe Prado
 
Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming Dr. Pankaj Zope
 
Drv13 power flex 755 programming with devicelogix
Drv13   power flex 755 programming with devicelogixDrv13   power flex 755 programming with devicelogix
Drv13 power flex 755 programming with devicelogixconfidencial
 
Larson and toubro
Larson and toubroLarson and toubro
Larson and toubroanoopc1998
 
HKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightHKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightLinaro
 
Reverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentalsReverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentalsEran Goldstein
 
Customizable Microprocessor design on Nexys 3 Spartan FPGA Board
Customizable Microprocessor design on Nexys 3 Spartan FPGA BoardCustomizable Microprocessor design on Nexys 3 Spartan FPGA Board
Customizable Microprocessor design on Nexys 3 Spartan FPGA BoardBharat Biyani
 
The Basics of programming
The Basics of programmingThe Basics of programming
The Basics of programming692sfrobotics
 
DPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet ProcessingDPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet ProcessingMichelle Holley
 
Lp 2010 operation-theory
Lp 2010 operation-theoryLp 2010 operation-theory
Lp 2010 operation-theoryNguyen Duc Anh
 
Debugging programs with Keil uVision
Debugging programs with Keil uVisionDebugging programs with Keil uVision
Debugging programs with Keil uVisionSaravananVijayakumar4
 
Introduction to C Language - Version 1.0 by Mark John Lado
Introduction to C Language - Version 1.0 by Mark John LadoIntroduction to C Language - Version 1.0 by Mark John Lado
Introduction to C Language - Version 1.0 by Mark John LadoMark John Lado, MIT
 
Itsp documentation quadcopter flight controller based on kalman filters
Itsp documentation   quadcopter flight controller based on kalman filtersItsp documentation   quadcopter flight controller based on kalman filters
Itsp documentation quadcopter flight controller based on kalman filtersJyotirmaya Mahanta
 

Similar to Micro c lab2(led patterns) (20)

20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris
 
Lab 1 reference manual
Lab 1 reference manualLab 1 reference manual
Lab 1 reference manual
 
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
 
Digital Alarm Clock 446 project report
Digital Alarm Clock 446 project reportDigital Alarm Clock 446 project report
Digital Alarm Clock 446 project report
 
Rodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationRodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementation
 
Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming
 
Drv13 power flex 755 programming with devicelogix
Drv13   power flex 755 programming with devicelogixDrv13   power flex 755 programming with devicelogix
Drv13 power flex 755 programming with devicelogix
 
Larson and toubro
Larson and toubroLarson and toubro
Larson and toubro
 
HKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightHKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with Coresight
 
Reverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentalsReverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentals
 
Xgt training
Xgt trainingXgt training
Xgt training
 
Customizable Microprocessor design on Nexys 3 Spartan FPGA Board
Customizable Microprocessor design on Nexys 3 Spartan FPGA BoardCustomizable Microprocessor design on Nexys 3 Spartan FPGA Board
Customizable Microprocessor design on Nexys 3 Spartan FPGA Board
 
The Basics of programming
The Basics of programmingThe Basics of programming
The Basics of programming
 
STM -32
STM -32STM -32
STM -32
 
learning STM -32
learning STM -32 learning STM -32
learning STM -32
 
DPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet ProcessingDPDK & Layer 4 Packet Processing
DPDK & Layer 4 Packet Processing
 
Lp 2010 operation-theory
Lp 2010 operation-theoryLp 2010 operation-theory
Lp 2010 operation-theory
 
Debugging programs with Keil uVision
Debugging programs with Keil uVisionDebugging programs with Keil uVision
Debugging programs with Keil uVision
 
Introduction to C Language - Version 1.0 by Mark John Lado
Introduction to C Language - Version 1.0 by Mark John LadoIntroduction to C Language - Version 1.0 by Mark John Lado
Introduction to C Language - Version 1.0 by Mark John Lado
 
Itsp documentation quadcopter flight controller based on kalman filters
Itsp documentation   quadcopter flight controller based on kalman filtersItsp documentation   quadcopter flight controller based on kalman filters
Itsp documentation quadcopter flight controller based on kalman filters
 

More from Mashood

Patience (1).pptx
Patience (1).pptxPatience (1).pptx
Patience (1).pptxMashood
 
Micro c lab8(serial communication)
Micro c lab8(serial communication)Micro c lab8(serial communication)
Micro c lab8(serial communication)Mashood
 
Micro c lab7(timers)
Micro c lab7(timers)Micro c lab7(timers)
Micro c lab7(timers)Mashood
 
Micro c lab6(lcd)
Micro c lab6(lcd)Micro c lab6(lcd)
Micro c lab6(lcd)Mashood
 
Micro c lab5(stepper-motor)
Micro c lab5(stepper-motor)Micro c lab5(stepper-motor)
Micro c lab5(stepper-motor)Mashood
 
Micro c lab4(keypad)
Micro c lab4(keypad)Micro c lab4(keypad)
Micro c lab4(keypad)Mashood
 
Micro c lab3(ssd)
Micro c lab3(ssd)Micro c lab3(ssd)
Micro c lab3(ssd)Mashood
 
Micro c lab1(intro to 8051)
Micro c lab1(intro to 8051)Micro c lab1(intro to 8051)
Micro c lab1(intro to 8051)Mashood
 
Amplifiers (analog electronics ii lab)
Amplifiers (analog electronics ii lab)Amplifiers (analog electronics ii lab)
Amplifiers (analog electronics ii lab)Mashood
 
Pcb design using proteus
Pcb design using proteusPcb design using proteus
Pcb design using proteusMashood
 
Function Generator
Function GeneratorFunction Generator
Function GeneratorMashood
 
Speed Measuring Circuit
Speed Measuring CircuitSpeed Measuring Circuit
Speed Measuring CircuitMashood
 

More from Mashood (12)

Patience (1).pptx
Patience (1).pptxPatience (1).pptx
Patience (1).pptx
 
Micro c lab8(serial communication)
Micro c lab8(serial communication)Micro c lab8(serial communication)
Micro c lab8(serial communication)
 
Micro c lab7(timers)
Micro c lab7(timers)Micro c lab7(timers)
Micro c lab7(timers)
 
Micro c lab6(lcd)
Micro c lab6(lcd)Micro c lab6(lcd)
Micro c lab6(lcd)
 
Micro c lab5(stepper-motor)
Micro c lab5(stepper-motor)Micro c lab5(stepper-motor)
Micro c lab5(stepper-motor)
 
Micro c lab4(keypad)
Micro c lab4(keypad)Micro c lab4(keypad)
Micro c lab4(keypad)
 
Micro c lab3(ssd)
Micro c lab3(ssd)Micro c lab3(ssd)
Micro c lab3(ssd)
 
Micro c lab1(intro to 8051)
Micro c lab1(intro to 8051)Micro c lab1(intro to 8051)
Micro c lab1(intro to 8051)
 
Amplifiers (analog electronics ii lab)
Amplifiers (analog electronics ii lab)Amplifiers (analog electronics ii lab)
Amplifiers (analog electronics ii lab)
 
Pcb design using proteus
Pcb design using proteusPcb design using proteus
Pcb design using proteus
 
Function Generator
Function GeneratorFunction Generator
Function Generator
 
Speed Measuring Circuit
Speed Measuring CircuitSpeed Measuring Circuit
Speed Measuring Circuit
 

Recently uploaded

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 

Recently uploaded (20)

YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 

Micro c lab2(led patterns)

  • 1. GENERATE PATTERNS ON LED USING 8051
  • 2. Objectives of the Lab  Interfacing LEDs using 8051 ports as output ports.  Generating Delay using Delay Subroutine.  Checking Working of Code on Proteus.  Programming 8051 using Smart-PRO Burner.
  • 3. Deciding Pins or Ports to use Use with caution If EA high, P0 & P2 are simple ports otherwise address bits *We can use any port, for now we will use P2.
  • 4. Introduction to Assembly in 8051  An assembly language instruction consists of four fields. [Label:] mnemonic [operands] [;comments]  Label is used to jump to a specific code location from any other location.  Mnemonic is used for opcode of command e.g. add, mov.  Operands are used to mention the registers or constants used by command.  Comment field is used to make the code user friendly.  Square brackets show that these fields are optional.
  • 5. Review Registers (Naming) Normally Used Accumulator (A or ACC) Base (B) Ports (P0,P1,P2,P3 & Px.y) PSW (For Flags & Register Banks) R0,R1,…,R7 SP(Stack Pointer) DPTR(Data Pointer) Timer Registers Serial Port Registers Interrupt Registers PCON (Power Control Register) IP (Instruction Pointer) Legend: * Frequently used * Special Functions * Occasionally * Used automatically
  • 6. Instructions used in this Lab  MOV DEST,SOURCE  mov p0,#10101001b  mov p0,#0A9h  mov p0,#169d or mov p0,#169  JMP LABEL  DJNZ REG,LABEL  RL A  RR A  See instruction set for the details of above commands.
  • 7. Algorithm to generate LED patterns Start Send seq to output First Sequence Next Sequence Call Delay *Controller Programs tend to run forever i.e. in the infinite loop. mov a,#seq mov p2,a rr a call delay
  • 8. Review Program Structure (Directives) org 00h . . . call delay . . . delay: ;subroutine . . . ret end
  • 9. Delay subroutine: delay: mov r6,#2 dl1: mov r7,#10 dl2: djnz r7,dl2 ; djnz r7,$ djnz r6,dl1 ret
  • 10. Delay Calculation delay: mov r6,#x dl1: mov r7,#y djnz r7,$ djnz r6,dl1 ret 1 1 2 * y * x 2 2 *Refer to instruction set for delays of individual commands Delay= (2y+1+2)x+1+2 =(2y+3)x+3 machine cycles  Putting in the values of x and y, we can calculate delay in machine cycles and then we can calculate the time by multiplying this by the time one machine cycle takes.
  • 11. Generating Required Delay 1. We discussed that the above subroutine creates delay of (2y+3)x+3 machine cycles. To convert this delay into time, we need to replace machine cycle by the time it takes. 2. For a 12 MHz crystal, 1mc = 1µs, and delay=(2y+3)x+3µs. 3. If we want to create delay of 100 milli-seconds, then 100ms=(2y+3)x+3µs, one equation, two unknown, assume some value of ‘y’ and find out ‘x’. 4. If the above calculated values of ‘x’ and ‘y’ are used, one will be able to generate delay of 100 ms, using a 12 MHz crystal. *Calculate values of x and y for generating delay of 100 ms with XTAL=11.0592 MHz
  • 12. Using Proteus to simulate 8051 codes 1. The ‘HEX’ file generated by ‘keil’ or any other software as such can be used to check the working of code on software using proteus. 2. Just search for ‘AT89c51’, place the controller, double click on it to edit properties 1. Change the clock frequency to 11.0592 MHz. 2. Click the ‘folder icon’ in front of Program files and locate the code hex file. 3. In advanced properties, select ‘Simulate Program Fetches’ and ‘Yes’. 3. Then, place other devices, interconnect with 8051 and simply play the simulation.
  • 13. How to program a µC using SmartPro 2008 (Programmer) 1. Connect your SmartPro 2008 Programmer to PC via USB port and turn the device on using its adapter. Also, place the µC carefully in the ZIF socket. 2. Locate and click ‘SmartPro 2008’ icon available on desktop. 3. If it asks for the Programmer Select ‘Smart PRO 5000u’ and click demo. *One must check, how to place different types of controller in the programmer.
  • 14. How to program a µC using SmartPro 2008 (Programmer) 4. Click ‘Select Device’ on the window or choose Device>Select or press Ctrl+S. 1. In ‘Type’, select ‘MCU’ 2. In ‘Manufacturer’, select ‘ATMEL’ , AT89Cxx. 3. In ‘Device’, select AT8951. 5. Now, select File>Open or press Ctrl+O, in ‘files of type’ select Intel Hex and locate the ‘HEX’ file you want to program. Also, see if buffer is loaded with the new ‘HEX’ file.
  • 15. How to program a µC using SmartPro 2008 (Programmer) 6. Now, there are a bunch of options that can be performed depending upon the users needs. 1. F4 or Click ‘Read’: Reads a previous program already burned in the µC. 2. F5 or ‘Erase’: Erases the previous program in µC. 3. F6 or ‘Blank Check’: Verification if program is erased. 4. F7 or ‘Program’: Loads the *current HEX file in µC. 5. F8 or ‘Verify’: Verification if the program is properly loaded. 6. ‘Batch’: This option is used in Industry. 7. Spacebar or ‘Auto’: Performs all the steps from 2 to 5 in sequence. 7. Shortcut: Open SmartPro, slect device, locate hex file & press spacebar.
  • 16. Debugging with µC 1. Unlike electronic circuits, the debugging with µC is different. Firstly, there is software debugging and then there is hardware debugging. 2. The software debugging includes the working of code. 3. The hardware debugging includes the working of code on hardware and the devices interfaced. 4. Always perform µC experiment in three stages, test the µC IC and generic board using led blinking, then verify the working of code on Proteus software, then finally test the program on hardware.
  • 17. Proteus Devices needed in this Lab 1. AT89c51 2. LED Bargraph 3. Resistor Pack
  • 18. Lab Tasks  Blink LED’s in different patterns with delay of 100 milli-seconds.  Pattern 1: Blink LEDs towards right.  Pattern 2: Blink LEDs towards left.  Pattern 3: Blink even LEDs only.  Pattern 4: Blink LEDs in the sequence 10000001,01000010,00100100,00011000.