SlideShare a Scribd company logo
1 of 94
MICROCONTROLLER-8051MICROCONTROLLER-8051
Features & ApplicationsFeatures & Applications
â€Ļâ€Ļ.... Man’s glory lies in his knowledge,Man’s glory lies in his knowledge,
his upright conduct, his praise-worthy character,his upright conduct, his praise-worthy character,
his wisdom, and not in his nationality or rankhis wisdom, and not in his nationality or rank
--Baha’ullah--Baha’ullah
(From, the book The 8051 Microcontroller and Embedded systems- Mazidi )(From, the book The 8051 Microcontroller and Embedded systems- Mazidi )
OverviewOverview
IntroductionIntroduction
Block Diagram andBlock Diagram and PinPin
Description of the 8051Description of the 8051
RegistersRegisters
Memory mapping in 8051Memory mapping in 8051
Stack in the 8051Stack in the 8051
I/O Port ProgrammingI/O Port Programming
TimersTimers
Interrupts &Interrupts &
ApplicationsApplications
īŽ Its not an exaggeration if I say that ,today
there is no electronic gadget on the earth
which is designed without a Microcontroller.
Ex: communication devices, digital
entertainment, portable devices etcâ€Ļ
Not believable ??? See the next slide
Why do we need to learnWhy do we need to learn
Microcontrollers ?Microcontrollers ?
īŽ Personal information products: Cell phone, pager,Personal information products: Cell phone, pager,
watch, pocket recorder, calculatorwatch, pocket recorder, calculator
īŽ Laptop components: mouse, keyboard, modem,Laptop components: mouse, keyboard, modem,
fax card, sound card, battery chargerfax card, sound card, battery charger
īŽ Home appliances: door lock, alarm clock,Home appliances: door lock, alarm clock,
thermostat, air conditioner, TV remote, VCR,thermostat, air conditioner, TV remote, VCR,
small refrigerator, exercise equipment,small refrigerator, exercise equipment,
washer/dryer, microwave ovenwasher/dryer, microwave oven
īŽ Industrial equipment: Temperature/pressureIndustrial equipment: Temperature/pressure
controllers, Counters, timers, RPM Controllerscontrollers, Counters, timers, RPM Controllers
īŽ Toys: video games, cars, dolls, etc.Toys: video games, cars, dolls, etc.
So, A good designer should always
know what type of controller he/she
is using ,their architecture, advantages ,
disadvantages , ways to reduce
production costs and product reliability
etcâ€Ļ.
O.K ????O.K ????
Then What is a Microcontroller ?
īŽ A smaller computer
īŽ On-chip RAM, ROM, I/O ports...
īŽ Example īŧš Motorola’s 6811, Intel’s 8051,
Zilog’s Z8 and PIC 16X
RAM ROM
I/O
Port
Timer
Serial
COM
Port
CPU
A single chip
Microcontroller
How is it different from aHow is it different from a
Microprocessor ??Microprocessor ??
īŽ General-purpose microprocessor
CPU for Computers
No RAM, ROM, I/O on CPU chip itself
Example īŧš Intel’s x86, Motorola’s 680x0
CPU
General-
Purpose
Micro-
processor
RAM ROM I/O
Port
Timer
Serial
COM
Port
Data Bus
Address Bus
Microprocessor
īŽ CPU is stand-alone, RAM,
ROM, I/O, timer are separate
īŽ designer can decide on the
amount of ROM, RAM and
I/O ports.
īŽ expansive
īŽ versatility
īŽ general-purpose
Microcontroller
â€ĸ CPU, RAM, ROM, I/O and
timer are all on a single chip
â€ĸ fix amount of on-chip ROM,
RAM, I/O ports
â€ĸ Highly bit addressable
â€ĸ for applications in which cost,
power and space are critical
â€ĸ single-purpose
Microprocessor vs. Microcontroller
EVOLUTIONEVOLUTION
Flashback !!!!Flashback !!!!
In the year 1976, Motorola created a MicroprocessorIn the year 1976, Motorola created a Microprocessor
chip called 6801 which replaced its brother 6800 withchip called 6801 which replaced its brother 6800 with
certain add-on chips to make a computer. This pavedcertain add-on chips to make a computer. This paved
the way for the new revolution in the history of chipthe way for the new revolution in the history of chip
design and gave birth to a new entity calleddesign and gave birth to a new entity called
MICROCONTROLLER.MICROCONTROLLER.
The INTEL bagged the credit of producing the firstThe INTEL bagged the credit of producing the first
Microcontroller 8048 with a CPU and 1K bytes ofMicrocontroller 8048 with a CPU and 1K bytes of
EPROM, 64 Bytes of RAM an 8-Bit Timer and 27 I/OEPROM, 64 Bytes of RAM an 8-Bit Timer and 27 I/O
pins in 1976.pins in 1976.
EvolutionEvolution contdcontdâ€Ļâ€Ļ
īŽ Then followed the most popular controller 8051Then followed the most popular controller 8051
in the year 1980 with 4K bytes of ROM,128in the year 1980 with 4K bytes of ROM,128
Bytes ofBytes of RAMRAM , a serial port, two 16-bit Timers ,, a serial port, two 16-bit Timers ,
and 32 I/O pins.and 32 I/O pins.
īŽ The 8051 family has many additions andThe 8051 family has many additions and
improvements over the years and remains aimprovements over the years and remains a
most soughtafter tool for todays circuitmost soughtafter tool for todays circuit
designers.designers.
īŽ The same INTEL introduced a 16 bit controllerThe same INTEL introduced a 16 bit controller
8096 in the year 19828096 in the year 1982
īŽ Later INTEL introduced 80c196 series of 16-bitLater INTEL introduced 80c196 series of 16-bit
microcontrollers for mainly industrialmicrocontrollers for mainly industrial
applicationsapplications
īŽ Microchip, another company has introduced aMicrochip, another company has introduced a
microcontroller PIC 16C64 an 8-bit in the yearmicrocontroller PIC 16C64 an 8-bit in the year
19851985..
īŽ 32-bit microcontrollers have been developed by IBM32-bit microcontrollers have been developed by IBM
and Motorola-MPC 505 is a 32-bit RISC controller ofand Motorola-MPC 505 is a 32-bit RISC controller of
MotorolaMotorola
īŽ The 403 GA is a 32 -bit RISC embedded controller ofThe 403 GA is a 32 -bit RISC embedded controller of
IBMIBM
ARM ControllersARM Controllers
īŽ In recent times ARM company (Advanced RiscIn recent times ARM company (Advanced Risc
machines) has developed and introduced 32 bitmachines) has developed and introduced 32 bit
controllers which are highend applicationcontrollers which are highend application
devices,especially communication devices likedevices,especially communication devices like
mobiles , ipods etc..(Refer www.arm.com)mobiles , ipods etc..(Refer www.arm.com)
Types of MicrocontrollersTypes of Microcontrollers
Microcontrollers from different manufacturersMicrocontrollers from different manufacturers
â€ĸAtmel
â€ĸARM
â€ĸIntel
â€ĸ8-bit
â€ĸ8XC42
â€ĸMCS48
â€ĸMCS51
â€ĸ8xC251
â€ĸ16-bit
â€ĸMCS96
â€ĸMXS296
â€ĸNational Semiconductor
â€ĸCOP8
â€ĸMicrochip
â€ĸ12-bit instruction PIC
â€ĸ14-bit instruction PIC
â€ĸPIC16F84
â€ĸ16-bit instruction PIC
â€ĸNEC
â€ĸMotorola
â€ĸ8-bit
â€ĸ68HC05
â€ĸ68HC08
â€ĸ68HC11
â€ĸ16-bit
â€ĸ68HC12
â€ĸ68HC16
â€ĸ32-bit
â€ĸ683xx
â€ĸTexas Instruments
â€ĸTMS370
â€ĸMSP430
â€ĸZilog
â€ĸZ8
â€ĸZ86E02
MCS-51 “Family” of MicrocontollersMCS-51 “Family” of Microcontollers
Feature 8031 8051 8052 8751Feature 8031 8051 8052 8751
ROMROM NONO 4kB 8kB 4kB UV Eprom4kB 8kB 4kB UV Eprom
RAM (Bytes) 128 128 256 128RAM (Bytes) 128 128 256 128
TIMERS 2 2 3 2TIMERS 2 2 3 2
I/O PINS 32 32 32 32I/O PINS 32 32 32 32
SERIAL PORTS 1 1 1 1SERIAL PORTS 1 1 1 1
INTERRUPTINTERRUPT 6 6 8 66 6 8 6
SOURCESSOURCES
Microcontroller ArchitecturesMicrocontroller Architectures
CPU
Program
+ Data
Address Bus
Data Bus
Memory
Von Neumann
Architecture
CPU
Program
Address Bus
Data Bus
Harvard
Architecture
Memory
Data
Address Bus
Fetch Bus
0
0
0
2n
Important Features of 8051Important Features of 8051
īŽ 4K bytes ROM4K bytes ROM
īŽ 128 bytes RAM128 bytes RAM
īŽ Four 8-bit I/O portsFour 8-bit I/O ports
īŽ Two 16-bit timersTwo 16-bit timers
īŽ Serial interfaceSerial interface
īŽ 64K external code memory space64K external code memory space
īŽ 64K data memory space64K data memory space
““Original” 8051 MicrocontrollerOriginal” 8051 Microcontroller
Oscillator
and timing
4096 Bytes
Program Memory
(ROM)
128 Bytes
Data Memory
(RAM)
Two 16 Bit
Timer/Event
Counters
8051
CPU
64 K Byte Bus
Expansion
Control
Programmable
I/O
Programmable
Serial Port Full
Duplex UART
Synchronous Shifter
Internal data bus
External interrupts
subsystem interrupts
Control Parallel ports
Address Data Bus
I/O pins
Serial Input
Serial Output
Pin Description of the 8051Pin Description of the 8051
īŽ The 8051 is a 40 pinThe 8051 is a 40 pin
device, but out ofdevice, but out of
these 40 pins, 32 arethese 40 pins, 32 are
used for I/O.used for I/O.
īŽ 24 of these are dual24 of these are dual
purpose, i.e. they canpurpose, i.e. they can
operate as I/O or aoperate as I/O or a
control line or as partcontrol line or as part
of address or dateof address or date
bus.bus.
8051 CPU Registers8051 CPU Registers
A (8-bit Accumulator)
B (8-bit register for Mul &Div)
PSW (8-bit Program Status Word)
SP (8-bit Stack Pointer)
PC (16-bit Program Counter)
DPTR (16-bit Data Pointer)
Special Function RegistersSpecial Function Registers
DATA registers
CONTROL registers
â€ĸTimers
â€ĸSerial ports
â€ĸInterrupt system
â€ĸAnalog to Digital converter
â€ĸDigital to Analog converter
etc..
Addresses 80h – FFh
Direct Addressing is used to
access SFRs
List of RegistersList of Registers
(*Denotes the SFRs)(*Denotes the SFRs)
Contdâ€ĻContdâ€Ļ
PSW REGISTERPSW REGISTER
Memory mapping in 8051Memory mapping in 8051
ROM memory map in 8051 family
0000H
0FFFH
0000H
1FFFH
0000H
7FFFH
8051
8752
4k
DS5000-32
8k 32k
from Atmel
Corporation
from Dallas
Semiconductor
RAM memory space allocation in the 8051
7FH
30H
2FH
20H
1FH
17H
10H
0FH
07H
08H
18H
00H
Register Bank 0
)Stack) Register Bank 1
Register Bank 2
Register Bank 3
Bit-Addressable RAM
Scratch pad RAM
PORTS OF 8051PORTS OF 8051
īŽ 8051 has 4 Ports. Port 0, Port1, Port2 , Port38051 has 4 Ports. Port 0, Port1, Port2 , Port3
īŽ Port 0 is a dual purpose port, it is located fromPort 0 is a dual purpose port, it is located from
pin 32 to pin 39 (8 pins). To use this port as bothpin 32 to pin 39 (8 pins). To use this port as both
input/output ports each pin must be connectedinput/output ports each pin must be connected
externally to a 10 k ohm pull-up resistor.This isexternally to a 10 k ohm pull-up resistor.This is
because Port 0 is an open drain.because Port 0 is an open drain.
Simple ex:Simple ex: MOV A, #22MOV A, #22
BACKBACK MOV P0 ,AP0 ,A
ACALL DELAYACALL DELAY
CPL ACPL A
SJMP BACKSJMP BACK
Port 0 with Pull-Up ResistorsPort 0 with Pull-Up Resistors
īŽ Port 1 is a dedicated I/O port from pin 1 to
pin 8.Upon reset it is configured as outport.
It is generally used for interfacing to
external device thus if you need to connect
to switches or LEDs, you could make use of
these 8 pins,but it doesn’t need any pull-up
resistors as it is having internally
īŽ Like port 0, port 2 is a dual-purpose port.(Pins 21Like port 0, port 2 is a dual-purpose port.(Pins 21
through 28) It can be used for general I/O or asthrough 28) It can be used for general I/O or as
the high byte of the address bus for designs withthe high byte of the address bus for designs with
external code memoryexternal code memory.Like P1 ,Port2 also doesn’t.Like P1 ,Port2 also doesn’t
require any pull-up resistorsrequire any pull-up resistors
Portsâ€Ļ.Portsâ€Ļ.
Ports contdâ€ĻPorts contdâ€Ļ
īŽ Port 3 is also dual purpose but designers generallyPort 3 is also dual purpose but designers generally
avoid using this port unnecessarily for I/Oavoid using this port unnecessarily for I/O
because the pins have alternate functions whichbecause the pins have alternate functions which
are related to special features of the 8051.are related to special features of the 8051.
Indiscriminate use of these pins may interfere withIndiscriminate use of these pins may interfere with
the normal operation of the 8051.the normal operation of the 8051.
īŽ However, for a programmer, it is the same to
program P0, P1, P2 and P3.
īŽ All the ports upon RESET are configured as
output. To use any of the ports as an input port,it
must be set(Programmed)
Alternate functions of P3Alternate functions of P3
I/O Port structureI/O Port structure
īŽ The internal circuitry for the I/O port is shown inThe internal circuitry for the I/O port is shown in
the next slidethe next slide
īŽ If you want to read in from a pin, you must firstIf you want to read in from a pin, you must first
give a logic ‘1’ to the port latch to turn off thegive a logic ‘1’ to the port latch to turn off the
FET otherwise the data read in will always be logicFET otherwise the data read in will always be logic
‘0’.‘0’.
īŽ When you write to the port you are actuallyWhen you write to the port you are actually
writing to the latch e.g. a logic 0 given to the latchwriting to the latch e.g. a logic 0 given to the latch
will be inverted and turn on the FET which causewill be inverted and turn on the FET which cause
the port pin to be connected to Gnd (logic 0).the port pin to be connected to Gnd (logic 0).
I/O Port contdâ€ĻI/O Port contdâ€Ļ
Timers /CountersTimers /Counters
īŽ The 8051 has 2 timers/counters:The 8051 has 2 timers/counters:
īŽ Timer/Counter 0Timer/Counter 0
īŽ Timer/Counter 1Timer/Counter 1
They can be used asThey can be used as
1.1. TheThe TimerTimer :Uused as a time delay generator.:Uused as a time delay generator.
īŽ The clock source is theThe clock source is the internalinternal crystal frequency of thecrystal frequency of the
8051.8051.
1.1. An eventAn event countercounter..
īŽ External inputExternal input from input pin to count the number offrom input pin to count the number of
events on registers.events on registers.
īŽ These clock pulses cold represent the number of peopleThese clock pulses cold represent the number of people
passing through an entrance, or the number of wheelpassing through an entrance, or the number of wheel
rotations, or any other event that can be converted to pulses.rotations, or any other event that can be converted to pulses.
TimerTimer
īŽ Set the initial value of registersSet the initial value of registers
īŽ Start the timer and then the 8051 counts up.Start the timer and then the 8051 counts up.
īŽ Input from internal system clock (machine cycle)Input from internal system clock (machine cycle)
īŽ When the registers equal to 0 and the 8051 sets aWhen the registers equal to 0 and the 8051 sets a
bit to denote time outbit to denote time out
to
LCD
P1
8051
TL0
TH0
P2
Set
Timer 0
CounterCounter
īŽ Count the number of eventsCount the number of events
īŽ Show the number of events on registersShow the number of events on registers
īŽ External input from T0 input pin (P3.4) for Counter 0External input from T0 input pin (P3.4) for Counter 0
īŽ External input from T1 input pin (P3.5) for Counter 1External input from T1 input pin (P3.5) for Counter 1
īŽ External inputExternal input from Tx input pin.from Tx input pin.
īŽ We use Tx to denote T0 or T1.We use Tx to denote T0 or T1.
T0
to
LCD
P3.4
P1
8051
a switch
TL0
TH0
RegistersRegisters Used in Timer/CounterUsed in Timer/Counter
īŽ 8051 has two 16-bit Timer registers ,Timer 0 &8051 has two 16-bit Timer registers ,Timer 0 &
Timer 1.Timer 1.
īŽ As 8051 has 8-bit architecture , each TimerAs 8051 has 8-bit architecture , each Timer
register is treated as two 8-bit registers namelyregister is treated as two 8-bit registers namely
TH0, TL0, TH1, TL1.TH0, TL0, TH1, TL1.
īŽ One 8-bit mode register -TMOD.One 8-bit mode register -TMOD.
īŽ One 8-bit control register-TCON.One 8-bit control register-TCON.
TMOD RegisterTMOD Register
īą Both Timer 0 &Timer 1 use the same Mode registerBoth Timer 0 &Timer 1 use the same Mode register
TMOD.TMOD.
īŽ It is an-8-bit register .The lower 4-bits are meant forIt is an-8-bit register .The lower 4-bits are meant for
Timer 0 &the uooer 4-bits are meant for Timer 1Timer 0 &the uooer 4-bits are meant for Timer 1
īŽ It is not bit addressible.It is not bit addressible.
īŽ It is used similar to any other register of 8051 . For ex:It is used similar to any other register of 8051 . For ex:
MOV TMOD,#21HMOV TMOD,#21H
GATE C/T M1 M0 GATE C/T M1 M0
Timer 1 Timer 0
(MSB) (LSB)
GateGate
īŽ Every timer has a mean of starting and stopping.Every timer has a mean of starting and stopping.
īŽ GATE=0GATE=0
īŽ InternalInternal controlcontrol
īŽ The start and stop of the timer are controlled by way ofThe start and stop of the timer are controlled by way of
software.software.
īŽ Set/clear the TR for start/stop timer.Set/clear the TR for start/stop timer.
SETB TR0SETB TR0
CLR TR0CLR TR0
īŽ GATE=1GATE=1
īŽ ExternalExternal controlcontrol
īŽ The hardware way of starting and stopping the timer byThe hardware way of starting and stopping the timer by
softwaresoftware andand an external sourcean external source..
īŽ Timer/counter is enabled only while the INT pin is high andTimer/counter is enabled only while the INT pin is high and
the TR control pin is set (TR).the TR control pin is set (TR).
TMod contdâ€Ļ.TMod contdâ€Ļ.
C/T :C/T : Timer or counter selected cleared for timer operation (inputTimer or counter selected cleared for timer operation (input
from internal system clock). Set for counter operationfrom internal system clock). Set for counter operation
(input from Tx input pin).(input from Tx input pin).
M1,M0 : Used for mode selection.Because the Timers of 8051 canUsed for mode selection.Because the Timers of 8051 can
be set in 4-different modes.be set in 4-different modes.
M1 M0 Mode OperationM1 M0 Mode Operation
0 00 0 00 113-bit timer3-bit timer mode 8-bit THx + 5-bit TLx (x= 0 or 1)mode 8-bit THx + 5-bit TLx (x= 0 or 1)
00 1 11 1 16-bit timer16-bit timer mode 8-bit THx + 8-bit TLxmode 8-bit THx + 8-bit TLx
1 01 0 22 8-bit auto reload8-bit auto reload 8-bit auto reload timer/counter;8-bit auto reload timer/counter;
THx holds a value which is to be reloaded intoTHx holds a value which is to be reloaded into
TLx each time it overflows.TLx each time it overflows.
11 11 33 Split timer modeSplit timer mode
TMod contdâ€ĻTMod contdâ€Ļ
Let us understand the working of Timer Mode 1Let us understand the working of Timer Mode 1
īŽ For this , let us consider timer 0 as an example.For this , let us consider timer 0 as an example.
īŽ 16-bit16-bit timer (TH0 and TL0)timer (TH0 and TL0)
īŽ TH0-TL0 is incremented continuously when TR0 is setTH0-TL0 is incremented continuously when TR0 is set
to 1. And the 8051 stops to increment TH0-TL0 whento 1. And the 8051 stops to increment TH0-TL0 when
TR0 is cleared.TR0 is cleared.
īŽ The timer works with the internal system clock. In otherThe timer works with the internal system clock. In other
words, the timer counts up each machine cycle.words, the timer counts up each machine cycle.
īŽ When the timer (TH0-TL0) reaches its maximum ofWhen the timer (TH0-TL0) reaches its maximum of
FFFFH, it rolls over to 0000, and TF0 is raised.FFFFH, it rolls over to 0000, and TF0 is raised.
īŽ Programmer should check TF0 and stop the timer 0.Programmer should check TF0 and stop the timer 0.
Steps of Mode 1Steps of Mode 1
1.1. Choose mode 1 timer 0Choose mode 1 timer 0
īŽ MOV TMOD,#01HMOV TMOD,#01H
1.1. Set the original value to TH0 and TL0.Set the original value to TH0 and TL0.
īŽ MOV TH0,#FFHMOV TH0,#FFH
īŽ MOV TL0,#FCHMOV TL0,#FCH
1.1. You better to clear the TF: TF0=0.You better to clear the TF: TF0=0.
īŽ CLR TF0CLR TF0
1.1. Start the timer.Start the timer.
īŽ SETB TR0SETB TR0
Mode 1 contdâ€ĻMode 1 contdâ€Ļ
5.5. The 8051 starts to count up by incrementing theThe 8051 starts to count up by incrementing the
TH0-TL0TH0-TL0..
īŽ TH0-TL0= FFFCH,FFFDH,FFFEH,FFFFH,0000HTH0-TL0= FFFCH,FFFDH,FFFEH,FFFFH,0000H
FFFC FFFD FFFE FFFF 0000
TF = 0 TF = 0 TF = 0 TF = 0 TF = 1
TH0 TL0Start timer
Stop timer
Monitor TF until TF=1
TR0=1 TR0=0
TF
Mode 1 contdâ€ĻMode 1 contdâ€Ļ
6.6. When TH0-TL0 rolls over from FFFFH toWhen TH0-TL0 rolls over from FFFFH to 0000,0000,
the 8051 set TF0=1.the 8051 set TF0=1.
TH0-TL0= FFFE H, FFFF H, 0000 H (NowTH0-TL0= FFFE H, FFFF H, 0000 H (Now
TF0=1)TF0=1)
6.6. Keep monitoring the timer flag )TF) to see if it isKeep monitoring the timer flag )TF) to see if it is
raised.raised.
AGAIN: JNB TF0, AGAINAGAIN: JNB TF0, AGAIN
6.6. Clear TR0 to stop the process.Clear TR0 to stop the process.
CLR TR0CLR TR0
6.6. Clear the TF flag for the next round.Clear the TF flag for the next round.
CLR TF0CLR TF0
TCON RegisterTCON Register
īŽTimer control register TMOD is a 8-bit
register which is bit addressable and in
which Upper nibble is for timer/counter,
lower nibble is for interrupts
Tcon contdâ€ĻTcon contdâ€Ļ
īŽ TR (Timer run control bit)
īŽ TR0 for Timer/counter 0; TR1 for Timer/counter 1.
īŽ TR is set by programmer to turn timer/counter on/off.
īŽ TR=0 : off (stop)
īŽ TR=1 : on (start)
īŽ TF (timer flag, control flag)
īŽ TF0 for timer/counter 0; TF1 for timer/counter 1.
īŽ TF is like a carry. Originally, TF=0. When TH-TL roll over to 0000
from FFFFH, the TF is set to 1.
īŽ TF=0 : not reach
īŽ TF=1: reach
īŽ If we enable interrupt, TF=1 will trigger ISR.
Equivalent Instructions for the TimerEquivalent Instructions for the Timer
Control RegisterControl Register
For timer 0For timer 0
SETB TR0SETB TR0 == SETB TCON.4SETB TCON.4
CLR TR0CLR TR0 == CLR TCON.4CLR TCON.4
SETB TF0SETB TF0 == SETB TCON.5SETB TCON.5
CLR TF0CLR TF0 == CLR TCON.5CLR TCON.5
For timer 1For timer 1
SETB TR1SETB TR1 == SETB TCON.6SETB TCON.6
CLR TR1CLR TR1 == CLR TCON.6CLR TCON.6
SETB TF1SETB TF1 == SETB TCON.7SETB TCON.7
CLR TF1CLR TF1 == CLR TCON.7CLR TCON.7
TF1 IT0IE0IT1IE1TR0TF0TR1
TCON: Timer/Counter Control Register
Simple applications using ports &TimersSimple applications using ports &Timers
īŽ Using a port ,by a simple program you can generate a SquareUsing a port ,by a simple program you can generate a Square
wave of any duty cycle.wave of any duty cycle.
HEREHERE :: SETB P1.0 (Make bit of Port 0 High)SETB P1.0 (Make bit of Port 0 High)
LCALL DELAYLCALL DELAY
CLR P1.0CLR P1.0
LCALL DELAYLCALL DELAY
SJMP HERE : Keep doing itSJMP HERE : Keep doing it
Here same delay is used for bothHere same delay is used for both
High & lowHigh & low
Square-wave of 66%duty cycle.Square-wave of 66%duty cycle.
HEREHERE : SETB P1.0 ( Make bit of Port 0 High): SETB P1.0 ( Make bit of Port 0 High)
LCALL DELAYLCALL DELAY
LCALL DELAYLCALL DELAY
CLR P1.0CLR P1.0
LCALL DELAYLCALL DELAY
SJMP HERE : Keep doing itSJMP HERE : Keep doing it
Square-wave generation using TimerSquare-wave generation using Timer
DELAY:
SETB TR0 ;start the timer 0
AGAIN: JNB TF0,AGAIN
CLR TR0 ;stop timer 0
CLR TF0 ;clear timer 0 flag
RET
īą Square wave of 50% duty on P1.5
īą Timer 0 is used
; each loop is a half clock
MOV TMOD,#01 ;Timer 0,mode 1(16-bit)
HERE: MOV TL0,#0F2H ;Timer value = FFF2H
MOV TH0,#0FFH
CPL P1.5
ACALL DELAY
SJMP HERE
8051- SERIAL COMMUNICATION8051- SERIAL COMMUNICATION
Basics of serial communicationBasics of serial communication
Types of Serial communicationsTypes of Serial communications
RxD and TxD pins in the 8051RxD and TxD pins in the 8051
īŽ The 8051 has two pins for transferring andThe 8051 has two pins for transferring and
receiving data by serial communication. Thesereceiving data by serial communication. These
two pins are part of the Port3(P3.0 &P3.1)two pins are part of the Port3(P3.0 &P3.1)
īŽ These pins are TTL compatible and hence theyThese pins are TTL compatible and hence they
require a line driver to make them RS232require a line driver to make them RS232
compatiblecompatible
īŽ Max232 chip is one such line driver in use.Max232 chip is one such line driver in use.
īŽ Serial communication is controlled by an 8-bitSerial communication is controlled by an 8-bit
register called SCON register,it is a bitregister called SCON register,it is a bit
addressable register.addressable register.
Interfacing to PCInterfacing to PC
SCON (Serial control) registerSCON (Serial control) register
SM0 , SM1SM0 , SM1
īŽ These two bits of SCON register determine the framingThese two bits of SCON register determine the framing
of data by specifying the number of bits per characterof data by specifying the number of bits per character
and start bit and stop bits. There are 4 serial modes.and start bit and stop bits. There are 4 serial modes.
SM0 SM1
0 0 Serial Mode 0
0 1 Serial Mode 1, 8 bit data,
1 stop bit, 1 start bit
1 0 Serial Mode 2
1 1 Serial Mode 3
RENREN,, TITI,, RIRI
īŽ REN (Receive Enable) also referred asREN (Receive Enable) also referred as SCON.4SCON.4..
When it is high,it allows the 8051 to receive dataWhen it is high,it allows the 8051 to receive data
on the RxD pin. So to receive and transfer dataon the RxD pin. So to receive and transfer data
REN must be set to 1.When REN=0,theREN must be set to 1.When REN=0,the
receiver is disabled. This is achieved as belowreceiver is disabled. This is achieved as below
SETB SCON.4SETB SCON.4
& CLR SCON.4& CLR SCON.4
Contdâ€ĻContdâ€Ļ
īŽ TI (Transmit interrupt) is the D1 bit of SCON register.TI (Transmit interrupt) is the D1 bit of SCON register.
When 8051 finishes the transfer of 8-bit character, itWhen 8051 finishes the transfer of 8-bit character, it
raises the TI flag to indicate that it is ready to transferraises the TI flag to indicate that it is ready to transfer
another byte. The TI bit is raised at the beginning ofanother byte. The TI bit is raised at the beginning of
the stop bit.the stop bit.
īŽ RI (Receive interrupt) is the D0 bit of the SCONRI (Receive interrupt) is the D0 bit of the SCON
register. When the 8051 receives data serially ,via RxD,register. When the 8051 receives data serially ,via RxD,
it gets rid of the start and stop bits and places the byteit gets rid of the start and stop bits and places the byte
in the SBUF register.Then it raises the RI flag bit toin the SBUF register.Then it raises the RI flag bit to
indicate that a byte has been received and should beindicate that a byte has been received and should be
picked up before it is lost.RI is raised halfway throughpicked up before it is lost.RI is raised halfway through
the stop bit.the stop bit.
8051 Interrupts8051 Interrupts
īŽ AnAn interruptinterrupt is an external or internal event thatis an external or internal event that disturbsdisturbs
thethe microcontroller to inform it that a device needs itsmicrocontroller to inform it that a device needs its
service.service.
AA MMicrocontroller can serveicrocontroller can serve variousvarious devices.devices.
īŽ ThThereere are two ways to do that:are two ways to do that:
īŽ interruptsinterrupts &&
īŽ polling.polling.
īŽ The program which is associated with the interrupt isThe program which is associated with the interrupt is
called thecalled the interrupt service routineinterrupt service routine (ISR) or(ISR) or interruptinterrupt
handlerhandler..
Steps in executing an interruptSteps in executing an interrupt
īŽ Upon receiving the interrupt signal theUpon receiving the interrupt signal the
Microcontroller , fMicrocontroller , finishinish currentcurrent instruction andinstruction and
ssaaves the PC on stack.ves the PC on stack.
īŽ JJumps to a fixed location in memoryumps to a fixed location in memory dependingdepending
on type of interrupton type of interrupt
īŽ SStarts to execute the interrupt service routinetarts to execute the interrupt service routine
until RETI (return from interrupt)until RETI (return from interrupt)
īŽ Upon executing the RETI the microcontrollerUpon executing the RETI the microcontroller
returns to the place where it was interrupted.returns to the place where it was interrupted.
GetGet poppop PC from stackPC from stack
Interrupt SourcesInterrupt Sources
īŽ Original 8051 has 6 sources of interruptsOriginal 8051 has 6 sources of interrupts
īŽ ResetReset
īŽ Timer 0 overflowTimer 0 overflow
īŽ Timer 1 overflowTimer 1 overflow
īŽ External Interrupt 0External Interrupt 0
īŽ External Interrupt 1External Interrupt 1
īŽ Serial Port events (buffer full, buffer empty, etc)Serial Port events (buffer full, buffer empty, etc)
īŽ Enhanced version has 22 sourcesEnhanced version has 22 sources
īŽ More timers, programmable counter array, ADC,More timers, programmable counter array, ADC,
more external interrupts, another serial port (UART)more external interrupts, another serial port (UART)
īŽ Each interrupt has a specific place in codeEach interrupt has a specific place in code
memory where program execution (interruptmemory where program execution (interrupt
service routine) begins.service routine) begins.
īŽ External Interrupt 0:External Interrupt 0: 0003h0003h
īŽ Timer 0 overflow:Timer 0 overflow: 000Bh000Bh
īŽ External Interrupt 1:External Interrupt 1: 0013h0013h
īŽ Timer 1 overflow:Timer 1 overflow: 001Bh001Bh
īŽ Serial : 0023hSerial : 0023h
īŽ Timer 2 overflowTimer 2 overflow(8052+)(8052+) 002bh002bh
Interrupt Vectors
Interrupt Enable RegisterInterrupt Enable Register
īŽ Upon reset all Interrupts are disabled & do
not respond to the Microcontroller
īŽ These interrupts must be enabled by software
in order for the Microcontroller to respond to
them.
īŽ This is done by an 8-bit register called
Interrupt Enable Register (IE).
īŽ EA : Global enable/disable.
īŽ --- : Undefined.
īŽ ET2 : Enable Timer 2 interrupt.
īŽ ES : Enable Serial port interrupt.
īŽ ET1 : Enable Timer 1 interrupt.
īŽ EX1 :Enable External 1 interrupt.
īŽ ET0 : Enable Timer 0 interrupt.
īŽ EX0 : Enable External 0 interrupt..
Enabling and disabling an
interrupt
īąBy bit operation
īąRecommended in the middle of program
SETB EA ;Enable All
SETB ET0 ;Enable Timer0 ovrf
SETB ET1 ;Enable Timer1 ovrf
SETB EX0 ;Enable INT0
SETB EX1 ;Enable INT1
SETB ES ;Enable Serial port
īąBy Mov instruction
īąRecommended in the first of program
MOV IE, #10010110B
SETB IE.7
SETB IE.1
SETB IE.3
SETB IE.0
SETB IE.2
SETB IE.4
īŽ What if two interrupt sources interrupt at the sameWhat if two interrupt sources interrupt at the same
time?time?
īŽ The interrupt with the highest PRIORITY getsThe interrupt with the highest PRIORITY gets
serviced first.serviced first.
īŽ All interrupts have a power on default priority order.All interrupts have a power on default priority order.
1.1. External interrupt 0 (INT0)External interrupt 0 (INT0)
2.2. Timer interrupt0 (TF0)Timer interrupt0 (TF0)
3.3. External interrupt 1 (INT1)External interrupt 1 (INT1)
4.4. Timer interrupt1 (TF1)Timer interrupt1 (TF1)
5.5. Serial communication (RI+TI)Serial communication (RI+TI)
īŽ Priority can also be set to “high” or “low” by IP reg.Priority can also be set to “high” or “low” by IP reg.
Interrupt PrioritiesInterrupt Priorities
Interrupt Priorities (IP) RegisterInterrupt Priorities (IP) Register
IP.7: reservedIP.7: reserved
IP.6: reservedIP.6: reserved
IP.5: Timer 2 interrupt priority bit (8052 only)IP.5: Timer 2 interrupt priority bit (8052 only)
IP.4: Serial port interrupt priority bitIP.4: Serial port interrupt priority bit
IP.3: Timer 1 interrupt priority bitIP.3: Timer 1 interrupt priority bit
IP.2: External interrupt 1 priority bitIP.2: External interrupt 1 priority bit
IP.1: Timer 0 interrupt priority bitIP.1: Timer 0 interrupt priority bit
IP.0: External interrupt 0 priority bitIP.0: External interrupt 0 priority bit
--- PX0PT0PX1PT1PSPT2---
Interrupt Priorities ExampleInterrupt Priorities Example
īŽ MOV IP , #00000100BMOV IP , #00000100B oror SETB IP.2SETB IP.2 gives prioritygives priority
orderorder
1.1. Int1Int1
2.2. Int0Int0
3.3. Timer0Timer0
4.4. Timer1Timer1
5.5. SerialSerial
īŽ MOV IP , #00001100BMOV IP , #00001100B gives priority ordergives priority order
1.1. Int1Int1
2.2. Timer1Timer1
3.3. Int0Int0
4.4. Timer0Timer0
5.5. SerialSerial
--- PX0PT0PX1PT1PSPT2---
Interrupt inside an interruptInterrupt inside an interrupt
--- PX0PT0PX1PT1PSPT2---
īŽ A high-priority interrupt can interrupt a low-A high-priority interrupt can interrupt a low-
priority interrupypriority interrupy
īŽ All interrupt are latched internallyAll interrupt are latched internally
īŽ Low-priority interrupt wait until 8051 hasLow-priority interrupt wait until 8051 has
finished servicing the high-priority interruptfinished servicing the high-priority interrupt
Applications of MicrocontrollersApplications of Microcontrollers
Simple Interfacing ExamplesSimple Interfacing Examples
Seven segment InterfacingSeven segment Interfacing
Traffic light controllerTraffic light controller
Closed loop control system-Closed loop control system-
Temperature control exampleTemperature control example
Recent Wonders
Recent Wonders contd ........Recent Wonders contd ........
Recent Wonders contd ........Recent Wonders contd ........
Books that have helped me to understand theBooks that have helped me to understand the
Microcontrollers & embedded systemsMicrocontrollers & embedded systems
1)1) Barr, Michael, Programming embedded sytemsBarr, Michael, Programming embedded sytems
in C and C++ - OReilly Publ.in C and C++ - OReilly Publ.
2)2) Raj Kamal, Embedded systems,Raj Kamal, Embedded systems, TMGTMG
3)3) Mazidi and Mazidi, The 8051 microcontrollerMazidi and Mazidi, The 8051 microcontroller
and embedded sytems - Pearson education.and embedded sytems - Pearson education.
4)4) Peatman,J.B. Design with microcontrollers andPeatman,J.B. Design with microcontrollers and
microcomputers, McGraw Hilmicrocomputers, McGraw Hil
5)5) Sewart. J.W. The 8051 Microcontroller Hardware,Sewart. J.W. The 8051 Microcontroller Hardware,
Software and Interfacing – Prentice HallSoftware and Interfacing – Prentice Hall
6) Ayala Kenneth, The 8051 Microntroller –Ayala Kenneth, The 8051 Microntroller –
Architecture, Programming and Applications –Architecture, Programming and Applications –
Delmar Publ.Delmar Publ.
7)7) Ajay Deshmukh, Microcontrollers – TATAAjay Deshmukh, Microcontrollers – TATA
McGraw HillMcGraw Hill
8)8) Rajkamal, Microcontrollers - Architecture,Rajkamal, Microcontrollers - Architecture,
Programming – Pearson Publ.Programming – Pearson Publ.
9) Myke Predko, Programming the 8051 Microcontroller –Myke Predko, Programming the 8051 Microcontroller –
McGraw HillMcGraw Hill
10)10) Michael J. Pont, Embedded C - Addison WeselyMichael J. Pont, Embedded C - Addison Wesely
Publ.Publ.
Useful websitesUseful websites
Useful websitesUseful websites contdâ€Ļcontdâ€Ļ
1.1. http://www.eg3.comhttp://www.eg3.com
2.2. http://www.ARM.MCU.comhttp://www.ARM.MCU.com
3.3. http://www.mcjournal.comhttp://www.mcjournal.com
4.4. http://www.iar.comhttp://www.iar.com
5.5. http://http://http://www.embedded.comhttp://www.embedded.com
6.6. http://www.powersoftsystems.comhttp://www.powersoftsystems.com
EpilogueEpilogue
īŽ The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.
---- Robert Frost
īŽ GOOD LUCK!

More Related Content

What's hot

Motorola 68hc11
Motorola 68hc11Motorola 68hc11
Motorola 68hc11gajani121
 
microprocessor 8085, micro-processor, micro-controller, 8085, microprocessor ...
microprocessor 8085, micro-processor, micro-controller, 8085, microprocessor ...microprocessor 8085, micro-processor, micro-controller, 8085, microprocessor ...
microprocessor 8085, micro-processor, micro-controller, 8085, microprocessor ...Anupam Sharma
 
Microcontroller presentation
Microcontroller presentationMicrocontroller presentation
Microcontroller presentationxavierpaulino
 
20838382 microprocessor-8085-notes
20838382 microprocessor-8085-notes20838382 microprocessor-8085-notes
20838382 microprocessor-8085-notesManikanteswar Madala
 
microcontroller vs microprocessor
microcontroller vs microprocessormicrocontroller vs microprocessor
microcontroller vs microprocessorsobhadevi
 
Intel 8085 Micro Processor
Intel 8085 Micro ProcessorIntel 8085 Micro Processor
Intel 8085 Micro Processorsilentsoul
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkarSAQUIB AHMAD
 
INTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLERINTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLERAnkita Jaiswal
 
The 8051 microcontroler based embedded systems
The 8051 microcontroler based embedded systemsThe 8051 microcontroler based embedded systems
The 8051 microcontroler based embedded systemsmanishpatel_79
 
8085 micro processor- notes
8085 micro  processor- notes8085 micro  processor- notes
8085 micro processor- notesDr.YNM
 
8085 microprocessor
8085 microprocessor8085 microprocessor
8085 microprocessorAnuja Gunale
 
8051 dev board guide
8051 dev board guide8051 dev board guide
8051 dev board guideMurali Krishna
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 MicrocontrollerJai Sudhan
 
Microprocessor vs. microcontroller
Microprocessor vs. microcontrollerMicroprocessor vs. microcontroller
Microprocessor vs. microcontrolleraviban
 
8051-microcontroller
8051-microcontroller8051-microcontroller
8051-microcontrollerjhcid
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontrollersanjay kumar
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086Waleed Khan
 

What's hot (20)

Unit 1
Unit 1Unit 1
Unit 1
 
Motorola 68hc11
Motorola 68hc11Motorola 68hc11
Motorola 68hc11
 
microprocessor 8085, micro-processor, micro-controller, 8085, microprocessor ...
microprocessor 8085, micro-processor, micro-controller, 8085, microprocessor ...microprocessor 8085, micro-processor, micro-controller, 8085, microprocessor ...
microprocessor 8085, micro-processor, micro-controller, 8085, microprocessor ...
 
Microcontroller presentation
Microcontroller presentationMicrocontroller presentation
Microcontroller presentation
 
20838382 microprocessor-8085-notes
20838382 microprocessor-8085-notes20838382 microprocessor-8085-notes
20838382 microprocessor-8085-notes
 
microcontroller vs microprocessor
microcontroller vs microprocessormicrocontroller vs microprocessor
microcontroller vs microprocessor
 
Intel 8085 Micro Processor
Intel 8085 Micro ProcessorIntel 8085 Micro Processor
Intel 8085 Micro Processor
 
MICROPROCESSOR & MICROCONTROLLER 8086,8051 Notes
MICROPROCESSOR & MICROCONTROLLER 8086,8051 NotesMICROPROCESSOR & MICROCONTROLLER 8086,8051 Notes
MICROPROCESSOR & MICROCONTROLLER 8086,8051 Notes
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkar
 
INTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLERINTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLER
 
The 8051 microcontroler based embedded systems
The 8051 microcontroler based embedded systemsThe 8051 microcontroler based embedded systems
The 8051 microcontroler based embedded systems
 
8085 micro processor- notes
8085 micro  processor- notes8085 micro  processor- notes
8085 micro processor- notes
 
8085 microprocessor
8085 microprocessor8085 microprocessor
8085 microprocessor
 
EE6502 Microprocessor & Microcontroller Regulation 2013
EE6502 Microprocessor & Microcontroller Regulation 2013EE6502 Microprocessor & Microcontroller Regulation 2013
EE6502 Microprocessor & Microcontroller Regulation 2013
 
8051 dev board guide
8051 dev board guide8051 dev board guide
8051 dev board guide
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontroller
 
Microprocessor vs. microcontroller
Microprocessor vs. microcontrollerMicroprocessor vs. microcontroller
Microprocessor vs. microcontroller
 
8051-microcontroller
8051-microcontroller8051-microcontroller
8051-microcontroller
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
 

Similar to 8051 Microcontroller Features & Applications Guide

Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051John Williams
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.pptKalaiSelvan911913
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051guest70d48b1
 
btech 8051 Microcontroller Programing.pptx
btech 8051 Microcontroller Programing.pptxbtech 8051 Microcontroller Programing.pptx
btech 8051 Microcontroller Programing.pptxSKWriters
 
8051mc notes-121004121921-phpapp01
8051mc notes-121004121921-phpapp018051mc notes-121004121921-phpapp01
8051mc notes-121004121921-phpapp01blacktricker
 
8051mc notes-121004121921-phpapp01
8051mc notes-121004121921-phpapp018051mc notes-121004121921-phpapp01
8051mc notes-121004121921-phpapp01ayushi sharma
 
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
EMBEDDED SYSTEMS AND IOT lab manual for enginnering studentsEMBEDDED SYSTEMS AND IOT lab manual for enginnering students
EMBEDDED SYSTEMS AND IOT lab manual for enginnering studentseceprinter6
 
8085 notes g scheme 2016
8085 notes g scheme 20168085 notes g scheme 2016
8085 notes g scheme 2016HarshitParkar6677
 
8085 notes g scheme 2016 (2)
8085 notes g scheme 2016 (2)8085 notes g scheme 2016 (2)
8085 notes g scheme 2016 (2)HarshitParkar6677
 
8085 notes g scheme 2016
8085 notes g scheme 20168085 notes g scheme 2016
8085 notes g scheme 2016HarshitParkar6677
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.pptDr.YNM
 
All about Microcontroller - 8051 ..pptx
All about Microcontroller -  8051 ..pptxAll about Microcontroller -  8051 ..pptx
All about Microcontroller - 8051 ..pptxBlackAdam7
 
Ashish microcontroller 8051
Ashish microcontroller 8051Ashish microcontroller 8051
Ashish microcontroller 8051ASHISH RAJ
 

Similar to 8051 Microcontroller Features & Applications Guide (20)

Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.ppt
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
8051 basics
8051 basics8051 basics
8051 basics
 
Mcu51
Mcu51Mcu51
Mcu51
 
btech 8051 Microcontroller Programing.pptx
btech 8051 Microcontroller Programing.pptxbtech 8051 Microcontroller Programing.pptx
btech 8051 Microcontroller Programing.pptx
 
8 bit microcontroller
8 bit microcontroller8 bit microcontroller
8 bit microcontroller
 
8051mc notes-121004121921-phpapp01
8051mc notes-121004121921-phpapp018051mc notes-121004121921-phpapp01
8051mc notes-121004121921-phpapp01
 
8051mc notes-121004121921-phpapp01
8051mc notes-121004121921-phpapp018051mc notes-121004121921-phpapp01
8051mc notes-121004121921-phpapp01
 
8085 notes g scheme
8085 notes g scheme8085 notes g scheme
8085 notes g scheme
 
8085 notes g scheme
8085 notes g scheme8085 notes g scheme
8085 notes g scheme
 
8051.pptx
8051.pptx8051.pptx
8051.pptx
 
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
EMBEDDED SYSTEMS AND IOT lab manual for enginnering studentsEMBEDDED SYSTEMS AND IOT lab manual for enginnering students
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
 
8085 notes g scheme 2016
8085 notes g scheme 20168085 notes g scheme 2016
8085 notes g scheme 2016
 
8085 notes g scheme 2016 (2)
8085 notes g scheme 2016 (2)8085 notes g scheme 2016 (2)
8085 notes g scheme 2016 (2)
 
8085 notes g scheme 2016
8085 notes g scheme 20168085 notes g scheme 2016
8085 notes g scheme 2016
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.ppt
 
All about Microcontroller - 8051 ..pptx
All about Microcontroller -  8051 ..pptxAll about Microcontroller -  8051 ..pptx
All about Microcontroller - 8051 ..pptx
 
8051 Presentation
8051 Presentation8051 Presentation
8051 Presentation
 
Ashish microcontroller 8051
Ashish microcontroller 8051Ashish microcontroller 8051
Ashish microcontroller 8051
 

More from jhcid

wireless-communication-architecture
 wireless-communication-architecture wireless-communication-architecture
wireless-communication-architecturejhcid
 
a-presentation-on-wireless-communication
 a-presentation-on-wireless-communication a-presentation-on-wireless-communication
a-presentation-on-wireless-communicationjhcid
 
sonar
sonarsonar
sonarjhcid
 
satellite-communications
 satellite-communications satellite-communications
satellite-communicationsjhcid
 
ppt-on-satellite
ppt-on-satelliteppt-on-satellite
ppt-on-satellitejhcid
 
satellite-communications
satellite-communicationssatellite-communications
satellite-communicationsjhcid
 
satellite-communication
 satellite-communication satellite-communication
satellite-communicationjhcid
 
satellite-communication-ppt
satellite-communication-pptsatellite-communication-ppt
satellite-communication-pptjhcid
 
radar
 radar radar
radarjhcid
 
radar
 radar radar
radarjhcid
 
radar-principles
radar-principlesradar-principles
radar-principlesjhcid
 
radar
radarradar
radarjhcid
 
cellular-communication
cellular-communicationcellular-communication
cellular-communicationjhcid
 
cellular communication
cellular communicationcellular communication
cellular communicationjhcid
 
-introduction-to-cellular-mobile-communications
-introduction-to-cellular-mobile-communications-introduction-to-cellular-mobile-communications
-introduction-to-cellular-mobile-communicationsjhcid
 
cellular-communications
 cellular-communications cellular-communications
cellular-communicationsjhcid
 
arduino-1
 arduino-1 arduino-1
arduino-1jhcid
 
arduino
 arduino arduino
arduinojhcid
 
arduino
arduinoarduino
arduinojhcid
 
arduino-ppt
 arduino-ppt arduino-ppt
arduino-pptjhcid
 

More from jhcid (20)

wireless-communication-architecture
 wireless-communication-architecture wireless-communication-architecture
wireless-communication-architecture
 
a-presentation-on-wireless-communication
 a-presentation-on-wireless-communication a-presentation-on-wireless-communication
a-presentation-on-wireless-communication
 
sonar
sonarsonar
sonar
 
satellite-communications
 satellite-communications satellite-communications
satellite-communications
 
ppt-on-satellite
ppt-on-satelliteppt-on-satellite
ppt-on-satellite
 
satellite-communications
satellite-communicationssatellite-communications
satellite-communications
 
satellite-communication
 satellite-communication satellite-communication
satellite-communication
 
satellite-communication-ppt
satellite-communication-pptsatellite-communication-ppt
satellite-communication-ppt
 
radar
 radar radar
radar
 
radar
 radar radar
radar
 
radar-principles
radar-principlesradar-principles
radar-principles
 
radar
radarradar
radar
 
cellular-communication
cellular-communicationcellular-communication
cellular-communication
 
cellular communication
cellular communicationcellular communication
cellular communication
 
-introduction-to-cellular-mobile-communications
-introduction-to-cellular-mobile-communications-introduction-to-cellular-mobile-communications
-introduction-to-cellular-mobile-communications
 
cellular-communications
 cellular-communications cellular-communications
cellular-communications
 
arduino-1
 arduino-1 arduino-1
arduino-1
 
arduino
 arduino arduino
arduino
 
arduino
arduinoarduino
arduino
 
arduino-ppt
 arduino-ppt arduino-ppt
arduino-ppt
 

Recently uploaded

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 

Recently uploaded (20)

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 

8051 Microcontroller Features & Applications Guide

  • 2. â€Ļâ€Ļ.... Man’s glory lies in his knowledge,Man’s glory lies in his knowledge, his upright conduct, his praise-worthy character,his upright conduct, his praise-worthy character, his wisdom, and not in his nationality or rankhis wisdom, and not in his nationality or rank --Baha’ullah--Baha’ullah (From, the book The 8051 Microcontroller and Embedded systems- Mazidi )(From, the book The 8051 Microcontroller and Embedded systems- Mazidi )
  • 3. OverviewOverview IntroductionIntroduction Block Diagram andBlock Diagram and PinPin Description of the 8051Description of the 8051 RegistersRegisters Memory mapping in 8051Memory mapping in 8051 Stack in the 8051Stack in the 8051 I/O Port ProgrammingI/O Port Programming TimersTimers Interrupts &Interrupts & ApplicationsApplications
  • 4. īŽ Its not an exaggeration if I say that ,today there is no electronic gadget on the earth which is designed without a Microcontroller. Ex: communication devices, digital entertainment, portable devices etcâ€Ļ Not believable ??? See the next slide Why do we need to learnWhy do we need to learn Microcontrollers ?Microcontrollers ?
  • 5. īŽ Personal information products: Cell phone, pager,Personal information products: Cell phone, pager, watch, pocket recorder, calculatorwatch, pocket recorder, calculator īŽ Laptop components: mouse, keyboard, modem,Laptop components: mouse, keyboard, modem, fax card, sound card, battery chargerfax card, sound card, battery charger īŽ Home appliances: door lock, alarm clock,Home appliances: door lock, alarm clock, thermostat, air conditioner, TV remote, VCR,thermostat, air conditioner, TV remote, VCR, small refrigerator, exercise equipment,small refrigerator, exercise equipment, washer/dryer, microwave ovenwasher/dryer, microwave oven īŽ Industrial equipment: Temperature/pressureIndustrial equipment: Temperature/pressure controllers, Counters, timers, RPM Controllerscontrollers, Counters, timers, RPM Controllers īŽ Toys: video games, cars, dolls, etc.Toys: video games, cars, dolls, etc.
  • 6. So, A good designer should always know what type of controller he/she is using ,their architecture, advantages , disadvantages , ways to reduce production costs and product reliability etcâ€Ļ. O.K ????O.K ????
  • 7. Then What is a Microcontroller ? īŽ A smaller computer īŽ On-chip RAM, ROM, I/O ports... īŽ Example īŧš Motorola’s 6811, Intel’s 8051, Zilog’s Z8 and PIC 16X RAM ROM I/O Port Timer Serial COM Port CPU A single chip Microcontroller
  • 8. How is it different from aHow is it different from a Microprocessor ??Microprocessor ?? īŽ General-purpose microprocessor CPU for Computers No RAM, ROM, I/O on CPU chip itself Example īŧš Intel’s x86, Motorola’s 680x0 CPU General- Purpose Micro- processor RAM ROM I/O Port Timer Serial COM Port Data Bus Address Bus
  • 9. Microprocessor īŽ CPU is stand-alone, RAM, ROM, I/O, timer are separate īŽ designer can decide on the amount of ROM, RAM and I/O ports. īŽ expansive īŽ versatility īŽ general-purpose Microcontroller â€ĸ CPU, RAM, ROM, I/O and timer are all on a single chip â€ĸ fix amount of on-chip ROM, RAM, I/O ports â€ĸ Highly bit addressable â€ĸ for applications in which cost, power and space are critical â€ĸ single-purpose Microprocessor vs. Microcontroller
  • 10. EVOLUTIONEVOLUTION Flashback !!!!Flashback !!!! In the year 1976, Motorola created a MicroprocessorIn the year 1976, Motorola created a Microprocessor chip called 6801 which replaced its brother 6800 withchip called 6801 which replaced its brother 6800 with certain add-on chips to make a computer. This pavedcertain add-on chips to make a computer. This paved the way for the new revolution in the history of chipthe way for the new revolution in the history of chip design and gave birth to a new entity calleddesign and gave birth to a new entity called MICROCONTROLLER.MICROCONTROLLER. The INTEL bagged the credit of producing the firstThe INTEL bagged the credit of producing the first Microcontroller 8048 with a CPU and 1K bytes ofMicrocontroller 8048 with a CPU and 1K bytes of EPROM, 64 Bytes of RAM an 8-Bit Timer and 27 I/OEPROM, 64 Bytes of RAM an 8-Bit Timer and 27 I/O pins in 1976.pins in 1976.
  • 11. EvolutionEvolution contdcontdâ€Ļâ€Ļ īŽ Then followed the most popular controller 8051Then followed the most popular controller 8051 in the year 1980 with 4K bytes of ROM,128in the year 1980 with 4K bytes of ROM,128 Bytes ofBytes of RAMRAM , a serial port, two 16-bit Timers ,, a serial port, two 16-bit Timers , and 32 I/O pins.and 32 I/O pins. īŽ The 8051 family has many additions andThe 8051 family has many additions and improvements over the years and remains aimprovements over the years and remains a most soughtafter tool for todays circuitmost soughtafter tool for todays circuit designers.designers. īŽ The same INTEL introduced a 16 bit controllerThe same INTEL introduced a 16 bit controller 8096 in the year 19828096 in the year 1982
  • 12. īŽ Later INTEL introduced 80c196 series of 16-bitLater INTEL introduced 80c196 series of 16-bit microcontrollers for mainly industrialmicrocontrollers for mainly industrial applicationsapplications īŽ Microchip, another company has introduced aMicrochip, another company has introduced a microcontroller PIC 16C64 an 8-bit in the yearmicrocontroller PIC 16C64 an 8-bit in the year 19851985.. īŽ 32-bit microcontrollers have been developed by IBM32-bit microcontrollers have been developed by IBM and Motorola-MPC 505 is a 32-bit RISC controller ofand Motorola-MPC 505 is a 32-bit RISC controller of MotorolaMotorola īŽ The 403 GA is a 32 -bit RISC embedded controller ofThe 403 GA is a 32 -bit RISC embedded controller of IBMIBM
  • 13. ARM ControllersARM Controllers īŽ In recent times ARM company (Advanced RiscIn recent times ARM company (Advanced Risc machines) has developed and introduced 32 bitmachines) has developed and introduced 32 bit controllers which are highend applicationcontrollers which are highend application devices,especially communication devices likedevices,especially communication devices like mobiles , ipods etc..(Refer www.arm.com)mobiles , ipods etc..(Refer www.arm.com)
  • 14. Types of MicrocontrollersTypes of Microcontrollers
  • 15. Microcontrollers from different manufacturersMicrocontrollers from different manufacturers â€ĸAtmel â€ĸARM â€ĸIntel â€ĸ8-bit â€ĸ8XC42 â€ĸMCS48 â€ĸMCS51 â€ĸ8xC251 â€ĸ16-bit â€ĸMCS96 â€ĸMXS296 â€ĸNational Semiconductor â€ĸCOP8 â€ĸMicrochip â€ĸ12-bit instruction PIC â€ĸ14-bit instruction PIC â€ĸPIC16F84 â€ĸ16-bit instruction PIC â€ĸNEC â€ĸMotorola â€ĸ8-bit â€ĸ68HC05 â€ĸ68HC08 â€ĸ68HC11 â€ĸ16-bit â€ĸ68HC12 â€ĸ68HC16 â€ĸ32-bit â€ĸ683xx â€ĸTexas Instruments â€ĸTMS370 â€ĸMSP430 â€ĸZilog â€ĸZ8 â€ĸZ86E02
  • 16. MCS-51 “Family” of MicrocontollersMCS-51 “Family” of Microcontollers Feature 8031 8051 8052 8751Feature 8031 8051 8052 8751 ROMROM NONO 4kB 8kB 4kB UV Eprom4kB 8kB 4kB UV Eprom RAM (Bytes) 128 128 256 128RAM (Bytes) 128 128 256 128 TIMERS 2 2 3 2TIMERS 2 2 3 2 I/O PINS 32 32 32 32I/O PINS 32 32 32 32 SERIAL PORTS 1 1 1 1SERIAL PORTS 1 1 1 1 INTERRUPTINTERRUPT 6 6 8 66 6 8 6 SOURCESSOURCES
  • 17. Microcontroller ArchitecturesMicrocontroller Architectures CPU Program + Data Address Bus Data Bus Memory Von Neumann Architecture CPU Program Address Bus Data Bus Harvard Architecture Memory Data Address Bus Fetch Bus 0 0 0 2n
  • 18. Important Features of 8051Important Features of 8051 īŽ 4K bytes ROM4K bytes ROM īŽ 128 bytes RAM128 bytes RAM īŽ Four 8-bit I/O portsFour 8-bit I/O ports īŽ Two 16-bit timersTwo 16-bit timers īŽ Serial interfaceSerial interface īŽ 64K external code memory space64K external code memory space īŽ 64K data memory space64K data memory space
  • 19. ““Original” 8051 MicrocontrollerOriginal” 8051 Microcontroller Oscillator and timing 4096 Bytes Program Memory (ROM) 128 Bytes Data Memory (RAM) Two 16 Bit Timer/Event Counters 8051 CPU 64 K Byte Bus Expansion Control Programmable I/O Programmable Serial Port Full Duplex UART Synchronous Shifter Internal data bus External interrupts subsystem interrupts Control Parallel ports Address Data Bus I/O pins Serial Input Serial Output
  • 20. Pin Description of the 8051Pin Description of the 8051 īŽ The 8051 is a 40 pinThe 8051 is a 40 pin device, but out ofdevice, but out of these 40 pins, 32 arethese 40 pins, 32 are used for I/O.used for I/O. īŽ 24 of these are dual24 of these are dual purpose, i.e. they canpurpose, i.e. they can operate as I/O or aoperate as I/O or a control line or as partcontrol line or as part of address or dateof address or date bus.bus.
  • 21. 8051 CPU Registers8051 CPU Registers A (8-bit Accumulator) B (8-bit register for Mul &Div) PSW (8-bit Program Status Word) SP (8-bit Stack Pointer) PC (16-bit Program Counter) DPTR (16-bit Data Pointer)
  • 22. Special Function RegistersSpecial Function Registers DATA registers CONTROL registers â€ĸTimers â€ĸSerial ports â€ĸInterrupt system â€ĸAnalog to Digital converter â€ĸDigital to Analog converter etc.. Addresses 80h – FFh Direct Addressing is used to access SFRs
  • 23. List of RegistersList of Registers (*Denotes the SFRs)(*Denotes the SFRs)
  • 26. Memory mapping in 8051Memory mapping in 8051 ROM memory map in 8051 family 0000H 0FFFH 0000H 1FFFH 0000H 7FFFH 8051 8752 4k DS5000-32 8k 32k from Atmel Corporation from Dallas Semiconductor
  • 27. RAM memory space allocation in the 8051 7FH 30H 2FH 20H 1FH 17H 10H 0FH 07H 08H 18H 00H Register Bank 0 )Stack) Register Bank 1 Register Bank 2 Register Bank 3 Bit-Addressable RAM Scratch pad RAM
  • 28. PORTS OF 8051PORTS OF 8051 īŽ 8051 has 4 Ports. Port 0, Port1, Port2 , Port38051 has 4 Ports. Port 0, Port1, Port2 , Port3 īŽ Port 0 is a dual purpose port, it is located fromPort 0 is a dual purpose port, it is located from pin 32 to pin 39 (8 pins). To use this port as bothpin 32 to pin 39 (8 pins). To use this port as both input/output ports each pin must be connectedinput/output ports each pin must be connected externally to a 10 k ohm pull-up resistor.This isexternally to a 10 k ohm pull-up resistor.This is because Port 0 is an open drain.because Port 0 is an open drain. Simple ex:Simple ex: MOV A, #22MOV A, #22 BACKBACK MOV P0 ,AP0 ,A ACALL DELAYACALL DELAY CPL ACPL A SJMP BACKSJMP BACK
  • 29. Port 0 with Pull-Up ResistorsPort 0 with Pull-Up Resistors
  • 30. īŽ Port 1 is a dedicated I/O port from pin 1 to pin 8.Upon reset it is configured as outport. It is generally used for interfacing to external device thus if you need to connect to switches or LEDs, you could make use of these 8 pins,but it doesn’t need any pull-up resistors as it is having internally īŽ Like port 0, port 2 is a dual-purpose port.(Pins 21Like port 0, port 2 is a dual-purpose port.(Pins 21 through 28) It can be used for general I/O or asthrough 28) It can be used for general I/O or as the high byte of the address bus for designs withthe high byte of the address bus for designs with external code memoryexternal code memory.Like P1 ,Port2 also doesn’t.Like P1 ,Port2 also doesn’t require any pull-up resistorsrequire any pull-up resistors Portsâ€Ļ.Portsâ€Ļ.
  • 31. Ports contdâ€ĻPorts contdâ€Ļ īŽ Port 3 is also dual purpose but designers generallyPort 3 is also dual purpose but designers generally avoid using this port unnecessarily for I/Oavoid using this port unnecessarily for I/O because the pins have alternate functions whichbecause the pins have alternate functions which are related to special features of the 8051.are related to special features of the 8051. Indiscriminate use of these pins may interfere withIndiscriminate use of these pins may interfere with the normal operation of the 8051.the normal operation of the 8051. īŽ However, for a programmer, it is the same to program P0, P1, P2 and P3. īŽ All the ports upon RESET are configured as output. To use any of the ports as an input port,it must be set(Programmed)
  • 32. Alternate functions of P3Alternate functions of P3
  • 33. I/O Port structureI/O Port structure īŽ The internal circuitry for the I/O port is shown inThe internal circuitry for the I/O port is shown in the next slidethe next slide īŽ If you want to read in from a pin, you must firstIf you want to read in from a pin, you must first give a logic ‘1’ to the port latch to turn off thegive a logic ‘1’ to the port latch to turn off the FET otherwise the data read in will always be logicFET otherwise the data read in will always be logic ‘0’.‘0’. īŽ When you write to the port you are actuallyWhen you write to the port you are actually writing to the latch e.g. a logic 0 given to the latchwriting to the latch e.g. a logic 0 given to the latch will be inverted and turn on the FET which causewill be inverted and turn on the FET which cause the port pin to be connected to Gnd (logic 0).the port pin to be connected to Gnd (logic 0).
  • 34. I/O Port contdâ€ĻI/O Port contdâ€Ļ
  • 35. Timers /CountersTimers /Counters īŽ The 8051 has 2 timers/counters:The 8051 has 2 timers/counters: īŽ Timer/Counter 0Timer/Counter 0 īŽ Timer/Counter 1Timer/Counter 1 They can be used asThey can be used as 1.1. TheThe TimerTimer :Uused as a time delay generator.:Uused as a time delay generator. īŽ The clock source is theThe clock source is the internalinternal crystal frequency of thecrystal frequency of the 8051.8051. 1.1. An eventAn event countercounter.. īŽ External inputExternal input from input pin to count the number offrom input pin to count the number of events on registers.events on registers. īŽ These clock pulses cold represent the number of peopleThese clock pulses cold represent the number of people passing through an entrance, or the number of wheelpassing through an entrance, or the number of wheel rotations, or any other event that can be converted to pulses.rotations, or any other event that can be converted to pulses.
  • 36. TimerTimer īŽ Set the initial value of registersSet the initial value of registers īŽ Start the timer and then the 8051 counts up.Start the timer and then the 8051 counts up. īŽ Input from internal system clock (machine cycle)Input from internal system clock (machine cycle) īŽ When the registers equal to 0 and the 8051 sets aWhen the registers equal to 0 and the 8051 sets a bit to denote time outbit to denote time out to LCD P1 8051 TL0 TH0 P2 Set Timer 0
  • 37. CounterCounter īŽ Count the number of eventsCount the number of events īŽ Show the number of events on registersShow the number of events on registers īŽ External input from T0 input pin (P3.4) for Counter 0External input from T0 input pin (P3.4) for Counter 0 īŽ External input from T1 input pin (P3.5) for Counter 1External input from T1 input pin (P3.5) for Counter 1 īŽ External inputExternal input from Tx input pin.from Tx input pin. īŽ We use Tx to denote T0 or T1.We use Tx to denote T0 or T1. T0 to LCD P3.4 P1 8051 a switch TL0 TH0
  • 38. RegistersRegisters Used in Timer/CounterUsed in Timer/Counter īŽ 8051 has two 16-bit Timer registers ,Timer 0 &8051 has two 16-bit Timer registers ,Timer 0 & Timer 1.Timer 1. īŽ As 8051 has 8-bit architecture , each TimerAs 8051 has 8-bit architecture , each Timer register is treated as two 8-bit registers namelyregister is treated as two 8-bit registers namely TH0, TL0, TH1, TL1.TH0, TL0, TH1, TL1. īŽ One 8-bit mode register -TMOD.One 8-bit mode register -TMOD. īŽ One 8-bit control register-TCON.One 8-bit control register-TCON.
  • 39. TMOD RegisterTMOD Register īą Both Timer 0 &Timer 1 use the same Mode registerBoth Timer 0 &Timer 1 use the same Mode register TMOD.TMOD. īŽ It is an-8-bit register .The lower 4-bits are meant forIt is an-8-bit register .The lower 4-bits are meant for Timer 0 &the uooer 4-bits are meant for Timer 1Timer 0 &the uooer 4-bits are meant for Timer 1 īŽ It is not bit addressible.It is not bit addressible. īŽ It is used similar to any other register of 8051 . For ex:It is used similar to any other register of 8051 . For ex: MOV TMOD,#21HMOV TMOD,#21H GATE C/T M1 M0 GATE C/T M1 M0 Timer 1 Timer 0 (MSB) (LSB)
  • 40. GateGate īŽ Every timer has a mean of starting and stopping.Every timer has a mean of starting and stopping. īŽ GATE=0GATE=0 īŽ InternalInternal controlcontrol īŽ The start and stop of the timer are controlled by way ofThe start and stop of the timer are controlled by way of software.software. īŽ Set/clear the TR for start/stop timer.Set/clear the TR for start/stop timer. SETB TR0SETB TR0 CLR TR0CLR TR0 īŽ GATE=1GATE=1 īŽ ExternalExternal controlcontrol īŽ The hardware way of starting and stopping the timer byThe hardware way of starting and stopping the timer by softwaresoftware andand an external sourcean external source.. īŽ Timer/counter is enabled only while the INT pin is high andTimer/counter is enabled only while the INT pin is high and the TR control pin is set (TR).the TR control pin is set (TR).
  • 41. TMod contdâ€Ļ.TMod contdâ€Ļ. C/T :C/T : Timer or counter selected cleared for timer operation (inputTimer or counter selected cleared for timer operation (input from internal system clock). Set for counter operationfrom internal system clock). Set for counter operation (input from Tx input pin).(input from Tx input pin). M1,M0 : Used for mode selection.Because the Timers of 8051 canUsed for mode selection.Because the Timers of 8051 can be set in 4-different modes.be set in 4-different modes. M1 M0 Mode OperationM1 M0 Mode Operation 0 00 0 00 113-bit timer3-bit timer mode 8-bit THx + 5-bit TLx (x= 0 or 1)mode 8-bit THx + 5-bit TLx (x= 0 or 1) 00 1 11 1 16-bit timer16-bit timer mode 8-bit THx + 8-bit TLxmode 8-bit THx + 8-bit TLx 1 01 0 22 8-bit auto reload8-bit auto reload 8-bit auto reload timer/counter;8-bit auto reload timer/counter; THx holds a value which is to be reloaded intoTHx holds a value which is to be reloaded into TLx each time it overflows.TLx each time it overflows. 11 11 33 Split timer modeSplit timer mode
  • 43. Let us understand the working of Timer Mode 1Let us understand the working of Timer Mode 1 īŽ For this , let us consider timer 0 as an example.For this , let us consider timer 0 as an example. īŽ 16-bit16-bit timer (TH0 and TL0)timer (TH0 and TL0) īŽ TH0-TL0 is incremented continuously when TR0 is setTH0-TL0 is incremented continuously when TR0 is set to 1. And the 8051 stops to increment TH0-TL0 whento 1. And the 8051 stops to increment TH0-TL0 when TR0 is cleared.TR0 is cleared. īŽ The timer works with the internal system clock. In otherThe timer works with the internal system clock. In other words, the timer counts up each machine cycle.words, the timer counts up each machine cycle. īŽ When the timer (TH0-TL0) reaches its maximum ofWhen the timer (TH0-TL0) reaches its maximum of FFFFH, it rolls over to 0000, and TF0 is raised.FFFFH, it rolls over to 0000, and TF0 is raised. īŽ Programmer should check TF0 and stop the timer 0.Programmer should check TF0 and stop the timer 0.
  • 44. Steps of Mode 1Steps of Mode 1 1.1. Choose mode 1 timer 0Choose mode 1 timer 0 īŽ MOV TMOD,#01HMOV TMOD,#01H 1.1. Set the original value to TH0 and TL0.Set the original value to TH0 and TL0. īŽ MOV TH0,#FFHMOV TH0,#FFH īŽ MOV TL0,#FCHMOV TL0,#FCH 1.1. You better to clear the TF: TF0=0.You better to clear the TF: TF0=0. īŽ CLR TF0CLR TF0 1.1. Start the timer.Start the timer. īŽ SETB TR0SETB TR0
  • 45. Mode 1 contdâ€ĻMode 1 contdâ€Ļ 5.5. The 8051 starts to count up by incrementing theThe 8051 starts to count up by incrementing the TH0-TL0TH0-TL0.. īŽ TH0-TL0= FFFCH,FFFDH,FFFEH,FFFFH,0000HTH0-TL0= FFFCH,FFFDH,FFFEH,FFFFH,0000H FFFC FFFD FFFE FFFF 0000 TF = 0 TF = 0 TF = 0 TF = 0 TF = 1 TH0 TL0Start timer Stop timer Monitor TF until TF=1 TR0=1 TR0=0 TF
  • 46. Mode 1 contdâ€ĻMode 1 contdâ€Ļ 6.6. When TH0-TL0 rolls over from FFFFH toWhen TH0-TL0 rolls over from FFFFH to 0000,0000, the 8051 set TF0=1.the 8051 set TF0=1. TH0-TL0= FFFE H, FFFF H, 0000 H (NowTH0-TL0= FFFE H, FFFF H, 0000 H (Now TF0=1)TF0=1) 6.6. Keep monitoring the timer flag )TF) to see if it isKeep monitoring the timer flag )TF) to see if it is raised.raised. AGAIN: JNB TF0, AGAINAGAIN: JNB TF0, AGAIN 6.6. Clear TR0 to stop the process.Clear TR0 to stop the process. CLR TR0CLR TR0 6.6. Clear the TF flag for the next round.Clear the TF flag for the next round. CLR TF0CLR TF0
  • 47. TCON RegisterTCON Register īŽTimer control register TMOD is a 8-bit register which is bit addressable and in which Upper nibble is for timer/counter, lower nibble is for interrupts
  • 48. Tcon contdâ€ĻTcon contdâ€Ļ īŽ TR (Timer run control bit) īŽ TR0 for Timer/counter 0; TR1 for Timer/counter 1. īŽ TR is set by programmer to turn timer/counter on/off. īŽ TR=0 : off (stop) īŽ TR=1 : on (start) īŽ TF (timer flag, control flag) īŽ TF0 for timer/counter 0; TF1 for timer/counter 1. īŽ TF is like a carry. Originally, TF=0. When TH-TL roll over to 0000 from FFFFH, the TF is set to 1. īŽ TF=0 : not reach īŽ TF=1: reach īŽ If we enable interrupt, TF=1 will trigger ISR.
  • 49. Equivalent Instructions for the TimerEquivalent Instructions for the Timer Control RegisterControl Register For timer 0For timer 0 SETB TR0SETB TR0 == SETB TCON.4SETB TCON.4 CLR TR0CLR TR0 == CLR TCON.4CLR TCON.4 SETB TF0SETB TF0 == SETB TCON.5SETB TCON.5 CLR TF0CLR TF0 == CLR TCON.5CLR TCON.5 For timer 1For timer 1 SETB TR1SETB TR1 == SETB TCON.6SETB TCON.6 CLR TR1CLR TR1 == CLR TCON.6CLR TCON.6 SETB TF1SETB TF1 == SETB TCON.7SETB TCON.7 CLR TF1CLR TF1 == CLR TCON.7CLR TCON.7 TF1 IT0IE0IT1IE1TR0TF0TR1 TCON: Timer/Counter Control Register
  • 50. Simple applications using ports &TimersSimple applications using ports &Timers īŽ Using a port ,by a simple program you can generate a SquareUsing a port ,by a simple program you can generate a Square wave of any duty cycle.wave of any duty cycle. HEREHERE :: SETB P1.0 (Make bit of Port 0 High)SETB P1.0 (Make bit of Port 0 High) LCALL DELAYLCALL DELAY CLR P1.0CLR P1.0 LCALL DELAYLCALL DELAY SJMP HERE : Keep doing itSJMP HERE : Keep doing it Here same delay is used for bothHere same delay is used for both High & lowHigh & low
  • 51. Square-wave of 66%duty cycle.Square-wave of 66%duty cycle. HEREHERE : SETB P1.0 ( Make bit of Port 0 High): SETB P1.0 ( Make bit of Port 0 High) LCALL DELAYLCALL DELAY LCALL DELAYLCALL DELAY CLR P1.0CLR P1.0 LCALL DELAYLCALL DELAY SJMP HERE : Keep doing itSJMP HERE : Keep doing it
  • 52. Square-wave generation using TimerSquare-wave generation using Timer DELAY: SETB TR0 ;start the timer 0 AGAIN: JNB TF0,AGAIN CLR TR0 ;stop timer 0 CLR TF0 ;clear timer 0 flag RET īą Square wave of 50% duty on P1.5 īą Timer 0 is used ; each loop is a half clock MOV TMOD,#01 ;Timer 0,mode 1(16-bit) HERE: MOV TL0,#0F2H ;Timer value = FFF2H MOV TH0,#0FFH CPL P1.5 ACALL DELAY SJMP HERE
  • 53. 8051- SERIAL COMMUNICATION8051- SERIAL COMMUNICATION
  • 54. Basics of serial communicationBasics of serial communication
  • 55. Types of Serial communicationsTypes of Serial communications
  • 56. RxD and TxD pins in the 8051RxD and TxD pins in the 8051 īŽ The 8051 has two pins for transferring andThe 8051 has two pins for transferring and receiving data by serial communication. Thesereceiving data by serial communication. These two pins are part of the Port3(P3.0 &P3.1)two pins are part of the Port3(P3.0 &P3.1) īŽ These pins are TTL compatible and hence theyThese pins are TTL compatible and hence they require a line driver to make them RS232require a line driver to make them RS232 compatiblecompatible īŽ Max232 chip is one such line driver in use.Max232 chip is one such line driver in use. īŽ Serial communication is controlled by an 8-bitSerial communication is controlled by an 8-bit register called SCON register,it is a bitregister called SCON register,it is a bit addressable register.addressable register.
  • 58. SCON (Serial control) registerSCON (Serial control) register
  • 59. SM0 , SM1SM0 , SM1 īŽ These two bits of SCON register determine the framingThese two bits of SCON register determine the framing of data by specifying the number of bits per characterof data by specifying the number of bits per character and start bit and stop bits. There are 4 serial modes.and start bit and stop bits. There are 4 serial modes. SM0 SM1 0 0 Serial Mode 0 0 1 Serial Mode 1, 8 bit data, 1 stop bit, 1 start bit 1 0 Serial Mode 2 1 1 Serial Mode 3
  • 60. RENREN,, TITI,, RIRI īŽ REN (Receive Enable) also referred asREN (Receive Enable) also referred as SCON.4SCON.4.. When it is high,it allows the 8051 to receive dataWhen it is high,it allows the 8051 to receive data on the RxD pin. So to receive and transfer dataon the RxD pin. So to receive and transfer data REN must be set to 1.When REN=0,theREN must be set to 1.When REN=0,the receiver is disabled. This is achieved as belowreceiver is disabled. This is achieved as below SETB SCON.4SETB SCON.4 & CLR SCON.4& CLR SCON.4
  • 61. Contdâ€ĻContdâ€Ļ īŽ TI (Transmit interrupt) is the D1 bit of SCON register.TI (Transmit interrupt) is the D1 bit of SCON register. When 8051 finishes the transfer of 8-bit character, itWhen 8051 finishes the transfer of 8-bit character, it raises the TI flag to indicate that it is ready to transferraises the TI flag to indicate that it is ready to transfer another byte. The TI bit is raised at the beginning ofanother byte. The TI bit is raised at the beginning of the stop bit.the stop bit. īŽ RI (Receive interrupt) is the D0 bit of the SCONRI (Receive interrupt) is the D0 bit of the SCON register. When the 8051 receives data serially ,via RxD,register. When the 8051 receives data serially ,via RxD, it gets rid of the start and stop bits and places the byteit gets rid of the start and stop bits and places the byte in the SBUF register.Then it raises the RI flag bit toin the SBUF register.Then it raises the RI flag bit to indicate that a byte has been received and should beindicate that a byte has been received and should be picked up before it is lost.RI is raised halfway throughpicked up before it is lost.RI is raised halfway through the stop bit.the stop bit.
  • 62. 8051 Interrupts8051 Interrupts īŽ AnAn interruptinterrupt is an external or internal event thatis an external or internal event that disturbsdisturbs thethe microcontroller to inform it that a device needs itsmicrocontroller to inform it that a device needs its service.service. AA MMicrocontroller can serveicrocontroller can serve variousvarious devices.devices. īŽ ThThereere are two ways to do that:are two ways to do that: īŽ interruptsinterrupts && īŽ polling.polling. īŽ The program which is associated with the interrupt isThe program which is associated with the interrupt is called thecalled the interrupt service routineinterrupt service routine (ISR) or(ISR) or interruptinterrupt handlerhandler..
  • 63. Steps in executing an interruptSteps in executing an interrupt īŽ Upon receiving the interrupt signal theUpon receiving the interrupt signal the Microcontroller , fMicrocontroller , finishinish currentcurrent instruction andinstruction and ssaaves the PC on stack.ves the PC on stack. īŽ JJumps to a fixed location in memoryumps to a fixed location in memory dependingdepending on type of interrupton type of interrupt īŽ SStarts to execute the interrupt service routinetarts to execute the interrupt service routine until RETI (return from interrupt)until RETI (return from interrupt) īŽ Upon executing the RETI the microcontrollerUpon executing the RETI the microcontroller returns to the place where it was interrupted.returns to the place where it was interrupted. GetGet poppop PC from stackPC from stack
  • 64. Interrupt SourcesInterrupt Sources īŽ Original 8051 has 6 sources of interruptsOriginal 8051 has 6 sources of interrupts īŽ ResetReset īŽ Timer 0 overflowTimer 0 overflow īŽ Timer 1 overflowTimer 1 overflow īŽ External Interrupt 0External Interrupt 0 īŽ External Interrupt 1External Interrupt 1 īŽ Serial Port events (buffer full, buffer empty, etc)Serial Port events (buffer full, buffer empty, etc) īŽ Enhanced version has 22 sourcesEnhanced version has 22 sources īŽ More timers, programmable counter array, ADC,More timers, programmable counter array, ADC, more external interrupts, another serial port (UART)more external interrupts, another serial port (UART)
  • 65. īŽ Each interrupt has a specific place in codeEach interrupt has a specific place in code memory where program execution (interruptmemory where program execution (interrupt service routine) begins.service routine) begins. īŽ External Interrupt 0:External Interrupt 0: 0003h0003h īŽ Timer 0 overflow:Timer 0 overflow: 000Bh000Bh īŽ External Interrupt 1:External Interrupt 1: 0013h0013h īŽ Timer 1 overflow:Timer 1 overflow: 001Bh001Bh īŽ Serial : 0023hSerial : 0023h īŽ Timer 2 overflowTimer 2 overflow(8052+)(8052+) 002bh002bh Interrupt Vectors
  • 66. Interrupt Enable RegisterInterrupt Enable Register īŽ Upon reset all Interrupts are disabled & do not respond to the Microcontroller īŽ These interrupts must be enabled by software in order for the Microcontroller to respond to them. īŽ This is done by an 8-bit register called Interrupt Enable Register (IE).
  • 67. īŽ EA : Global enable/disable. īŽ --- : Undefined. īŽ ET2 : Enable Timer 2 interrupt. īŽ ES : Enable Serial port interrupt. īŽ ET1 : Enable Timer 1 interrupt. īŽ EX1 :Enable External 1 interrupt. īŽ ET0 : Enable Timer 0 interrupt. īŽ EX0 : Enable External 0 interrupt..
  • 68. Enabling and disabling an interrupt īąBy bit operation īąRecommended in the middle of program SETB EA ;Enable All SETB ET0 ;Enable Timer0 ovrf SETB ET1 ;Enable Timer1 ovrf SETB EX0 ;Enable INT0 SETB EX1 ;Enable INT1 SETB ES ;Enable Serial port īąBy Mov instruction īąRecommended in the first of program MOV IE, #10010110B SETB IE.7 SETB IE.1 SETB IE.3 SETB IE.0 SETB IE.2 SETB IE.4
  • 69. īŽ What if two interrupt sources interrupt at the sameWhat if two interrupt sources interrupt at the same time?time? īŽ The interrupt with the highest PRIORITY getsThe interrupt with the highest PRIORITY gets serviced first.serviced first. īŽ All interrupts have a power on default priority order.All interrupts have a power on default priority order. 1.1. External interrupt 0 (INT0)External interrupt 0 (INT0) 2.2. Timer interrupt0 (TF0)Timer interrupt0 (TF0) 3.3. External interrupt 1 (INT1)External interrupt 1 (INT1) 4.4. Timer interrupt1 (TF1)Timer interrupt1 (TF1) 5.5. Serial communication (RI+TI)Serial communication (RI+TI) īŽ Priority can also be set to “high” or “low” by IP reg.Priority can also be set to “high” or “low” by IP reg. Interrupt PrioritiesInterrupt Priorities
  • 70. Interrupt Priorities (IP) RegisterInterrupt Priorities (IP) Register IP.7: reservedIP.7: reserved IP.6: reservedIP.6: reserved IP.5: Timer 2 interrupt priority bit (8052 only)IP.5: Timer 2 interrupt priority bit (8052 only) IP.4: Serial port interrupt priority bitIP.4: Serial port interrupt priority bit IP.3: Timer 1 interrupt priority bitIP.3: Timer 1 interrupt priority bit IP.2: External interrupt 1 priority bitIP.2: External interrupt 1 priority bit IP.1: Timer 0 interrupt priority bitIP.1: Timer 0 interrupt priority bit IP.0: External interrupt 0 priority bitIP.0: External interrupt 0 priority bit --- PX0PT0PX1PT1PSPT2---
  • 71. Interrupt Priorities ExampleInterrupt Priorities Example īŽ MOV IP , #00000100BMOV IP , #00000100B oror SETB IP.2SETB IP.2 gives prioritygives priority orderorder 1.1. Int1Int1 2.2. Int0Int0 3.3. Timer0Timer0 4.4. Timer1Timer1 5.5. SerialSerial īŽ MOV IP , #00001100BMOV IP , #00001100B gives priority ordergives priority order 1.1. Int1Int1 2.2. Timer1Timer1 3.3. Int0Int0 4.4. Timer0Timer0 5.5. SerialSerial --- PX0PT0PX1PT1PSPT2---
  • 72. Interrupt inside an interruptInterrupt inside an interrupt --- PX0PT0PX1PT1PSPT2--- īŽ A high-priority interrupt can interrupt a low-A high-priority interrupt can interrupt a low- priority interrupypriority interrupy īŽ All interrupt are latched internallyAll interrupt are latched internally īŽ Low-priority interrupt wait until 8051 hasLow-priority interrupt wait until 8051 has finished servicing the high-priority interruptfinished servicing the high-priority interrupt
  • 74. Simple Interfacing ExamplesSimple Interfacing Examples
  • 75. Seven segment InterfacingSeven segment Interfacing
  • 77.
  • 78. Closed loop control system-Closed loop control system- Temperature control exampleTemperature control example
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 88. Recent Wonders contd ........Recent Wonders contd ........
  • 89. Recent Wonders contd ........Recent Wonders contd ........
  • 90. Books that have helped me to understand theBooks that have helped me to understand the Microcontrollers & embedded systemsMicrocontrollers & embedded systems 1)1) Barr, Michael, Programming embedded sytemsBarr, Michael, Programming embedded sytems in C and C++ - OReilly Publ.in C and C++ - OReilly Publ. 2)2) Raj Kamal, Embedded systems,Raj Kamal, Embedded systems, TMGTMG 3)3) Mazidi and Mazidi, The 8051 microcontrollerMazidi and Mazidi, The 8051 microcontroller and embedded sytems - Pearson education.and embedded sytems - Pearson education. 4)4) Peatman,J.B. Design with microcontrollers andPeatman,J.B. Design with microcontrollers and microcomputers, McGraw Hilmicrocomputers, McGraw Hil
  • 91. 5)5) Sewart. J.W. The 8051 Microcontroller Hardware,Sewart. J.W. The 8051 Microcontroller Hardware, Software and Interfacing – Prentice HallSoftware and Interfacing – Prentice Hall 6) Ayala Kenneth, The 8051 Microntroller –Ayala Kenneth, The 8051 Microntroller – Architecture, Programming and Applications –Architecture, Programming and Applications – Delmar Publ.Delmar Publ. 7)7) Ajay Deshmukh, Microcontrollers – TATAAjay Deshmukh, Microcontrollers – TATA McGraw HillMcGraw Hill 8)8) Rajkamal, Microcontrollers - Architecture,Rajkamal, Microcontrollers - Architecture, Programming – Pearson Publ.Programming – Pearson Publ. 9) Myke Predko, Programming the 8051 Microcontroller –Myke Predko, Programming the 8051 Microcontroller – McGraw HillMcGraw Hill 10)10) Michael J. Pont, Embedded C - Addison WeselyMichael J. Pont, Embedded C - Addison Wesely Publ.Publ.
  • 93. Useful websitesUseful websites contdâ€Ļcontdâ€Ļ 1.1. http://www.eg3.comhttp://www.eg3.com 2.2. http://www.ARM.MCU.comhttp://www.ARM.MCU.com 3.3. http://www.mcjournal.comhttp://www.mcjournal.com 4.4. http://www.iar.comhttp://www.iar.com 5.5. http://http://http://www.embedded.comhttp://www.embedded.com 6.6. http://www.powersoftsystems.comhttp://www.powersoftsystems.com
  • 94. EpilogueEpilogue īŽ The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep. ---- Robert Frost īŽ GOOD LUCK!

Editor's Notes

  1. Program memory – RAM or ROM? Data memory – RAM or ROM?