SlideShare a Scribd company logo
MICROCONTROLLER-8051 Features & Applications Dr. Y .Narasimha  Murthy  Ph.D., Sri Saibaba National College (Autonomous) ANANTAPUR-515001(A.P)
… ..  Man’s glory lies in his knowledge, his upright conduct, his praise-worthy character, his wisdom, and not in his nationality or rank --Baha’ullah (From, the book The 8051 Microcontroller and Embedded systems-  Mazidi )
Overview Introduction Block Diagram and  Pin Description of the 8051 Registers Memory mapping in 8051  Stack in the 8051 I/O Port Programming Timers Interrupts  & Applications
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 learn Microcontrollers ?
Personal information products: Cell phone, pager, watch, pocket recorder, calculator Laptop components:  mouse, keyboard, modem, fax card, sound card, battery charger Home appliances:  door lock, alarm clock, thermostat, air conditioner, TV remote, VCR, small refrigerator, exercise equipment, washer/dryer, microwave oven Industrial equipment: Temperature/pressure controllers, Counters, timers, RPM Controllers  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  ????
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 a 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
EVOLUTION   Flashback !!!! In the year 1976, Motorola created a Microprocessor chip called 6801 which replaced its brother 6800 with certain add-on  chips to make a computer. This paved the way for the new revolution in the history of chip design and gave birth to a new entity called   MICROCONTROLLER. The INTEL bagged the credit of producing the first Microcontroller  8048 with a CPU and 1K bytes of EPROM, 64 Bytes of RAM an 8-Bit Timer and 27 I/O pins  in 1976.
Evolution  contd … Then followed the most popular controller 8051 in the year 1980 with 4K bytes of ROM,128 Bytes of  RAM  , a serial port, two 16-bit Timers , and 32 I/O pins. The 8051 family has many additions and improvements over the years and remains a most soughtafter tool for todays circuit designers. The same INTEL introduced a 16 bit controller 8096 in the year 1982
Later INTEL introduced 80c196 series of 16-bit microcontrollers for mainly industrial applications Microchip, another company has introduced a microcontroller PIC 16C64 an 8-bit in the year 1985 . 32-bit microcontrollers have been developed by IBM and Motorola-MPC 505 is a 32-bit RISC controller of Motorola The 403 GA is a 32 -bit RISC embedded controller of IBM
ARM Controllers In recent times ARM company (Advanced Risc machines) has developed and introduced 32 bit controllers which are highend application devices,especially communication devices like mobiles , ipods etc..(Refer www.arm.com)
Types of  Microcontrollers
Microcontrollers 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 Microcontollers Feature  8031  8051  8052  8751  ROM  NO   4kB  8kB  4kB UV Eprom RAM (Bytes)  128  128  256  128 TIMERS  2  2  3  2 I/O PINS  32  32  32  32 SERIAL PORTS  1  1  1  1 INTERRUPT  6  6  8  6 SOURCES
Microcontroller 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 2 n
Important Features of 8051 4K bytes ROM 128 bytes RAM Four 8-bit I/O ports Two 16-bit timers Serial interface 64K external code memory space 64K data memory space
“Original” 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
The 8051 is a 40 pin device, but out of these 40 pins, 32 are used for I/O.  24 of these are dual purpose, i.e. they can operate as I/O or a control line or as part of address or date bus. Pin Description of the 8051
8051 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 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 Registers (*Denotes the SFRs)
Contd…
PSW REGISTER
Memory mapping in 8051  ROM memory map in 8051 family 4k DS5000-32 8k 32k from Atmel Corporation from Dallas Semiconductor 0000H 0FFFH 0000H 1FFFH 0000H 7FFFH 8051 8752
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 8051 8051 has 4 Ports. Port 0, Port1, Port2 ,  Port3 Port 0 is a dual purpose port, it is located from pin 32 to pin 39 (8 pins). To use this port as both input/output ports each pin must be connected externally to a 10 k ohm pull-up resistor.This is because Port 0 is an open drain.  Simple ex:  MOV A, #22 BACK  MOV P0 ,A ACALL DELAY CPL A SJMP BACK
Port 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 21 through 28) It can be used for general I/O or as the high byte of the address bus for designs with external code memory .Like P1 ,Port2 also doesn’t require any pull-up resistors Ports….
Ports contd… Port 3 is also dual purpose but designers generally avoid using this port unnecessarily for I/O because the pins have alternate functions which are related to special features of the 8051.  Indiscriminate use of these pins may interfere with 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 P3
I/O Port structure The internal circuitry for the I/O port is shown in the next slide If you want to read in from a pin, you must first give a logic ‘1’ to the port latch to turn off the FET otherwise the data read in will always be logic ‘0’. When you write to the port you are actually writing to the latch e.g. a logic 0 given to the latch will be inverted and turn on the FET which cause the port pin to be connected to Gnd (logic 0).
I/O Port contd…
Timers /Counters   The 8051 has 2 timers/counters:  Timer/Counter 0  Timer/Counter 1 They can be used as The   Timer  :Uused as a time delay generator. The clock source is the  internal  crystal frequency of the 8051. An event  counter . External input  from input pin to count the number of events on registers. These clock pulses cold represent the number of people passing through an entrance, or the number of wheel rotations, or any other event that can be converted to pulses.
Timer  Set the initial value of registers Start the timer and then the 8051 counts up. Input from internal system clock (machine cycle) When the registers equal to 0 and the 8051 sets a bit to denote time out to LCD P1 8051 TL0 TH0 P2 Set Timer 0
Counter Count the number of events Show the number of events on registers External input from T0 input pin (P3.4) for Counter 0 External input from T1 input pin (P3.5) for Counter 1 External input  from Tx input pin.  We use Tx to denote T0 or T1. T0 to LCD P3.4 P1 8051 a switch TL0 TH0
Registers   Used in Timer/Counter 8051 has two 16-bit Timer registers ,Timer 0 & Timer 1. As 8051 has 8-bit architecture , each  Timer register is  treated as two 8-bit registers namely TH0, TL0, TH1, TL1.  One 8-bit mode register -TMOD. One 8-bit control register-TCON.
TMOD Register Both Timer 0 &Timer 1 use the same Mode register TMOD. It is an-8-bit register .The lower 4-bits are meant for Timer 0 &the uooer 4-bits are meant for Timer 1 It is not bit addressible. It is used similar to any other register of 8051 . For ex: MOV TMOD,#21H GATE C/T M1 M0 GATE C/T M1 M0 Timer 1 Timer 0 (MSB) (LSB)
Gate Every timer has a mean of starting and stopping. GATE=0 Internal  control The start and stop of the timer are controlled by way of  software. Set/clear the TR for start/stop timer. SETB TR0 CLR  TR0 GATE=1 External  control The hardware way of starting and stopping the timer by  software  and  an external source . Timer/counter is enabled only while the INT pin is high and the TR control pin is set (TR).
TMod contd…. C/T :   Timer or counter selected cleared for timer operation (input from internal system clock). Set for counter operation (input from Tx input pin). M1,M0 :  Used for mode selection.Because the Timers of 8051 can be set in 4-different modes. M1  M0  Mode  Operation 0  0  0   1 3-bit timer  mode 8-bit THx + 5-bit TLx  (x= 0  or 1) 0   1  1  16-bit timer  mode  8-bit THx + 8-bit TLx  1  0   2   8-bit auto reload   8-bit auto reload timer/counter;  THx holds a value which is to be reloaded into TLx each time it overflows. 1  1   3   Split timer mode
TMod contd…
Let us understand the working of Timer Mode 1 For this , let us consider timer 0 as an example. 16-bit  timer (TH0 and TL0) TH0-TL0 is incremented continuously when TR0 is set to 1. And the 8051 stops to increment TH0-TL0 when TR0 is cleared. The timer works with the internal system clock. In other words,  the timer counts up each machine cycle. When the timer (TH0-TL0) reaches its maximum of FFFFH, it rolls over to 0000, and TF0 is raised. Programmer should check TF0 and stop the timer 0.
Steps of Mode 1   Choose mode 1 timer 0 MOV TMOD,#01H Set the original value to TH0 and TL0. MOV TH0,#FFH MOV TL0,#FCH You  better to clear the TF: TF0=0. CLR TF0 Start the timer. SETB TR0
Mode 1 contd… The 8051 starts to count up by incrementing the TH0-TL0 . TH0-TL0= FFFCH,FFFDH,FFFEH,FFFFH,0000H TF = 0 TF = 0 TF = 0 TF = 0 TF = 1 TH0 TL0 Start timer Stop timer Monitor TF until TF=1 TR0=1 TR0=0 TF FFFC FFFD FFFE FFFF 0000
Mode 1  contd… When TH0-TL0 rolls over from FFFFH to   0000, the 8051 set TF0=1.  TH0-TL0= FFFE H, FFFF H, 0000 H (Now TF0=1) Keep monitoring the timer flag (TF) to see if it is raised. AGAIN:  JNB TF0, AGAIN   Clear TR0 to stop the process. CLR TR0 Clear the TF flag for the next round. CLR TF0
TCON 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… 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 Timer Control Register TCON: Timer/Counter Control Register CLR  TCON.7 = CLR  TF1 SETB TCON.7 = SETB TF1 CLR  TCON.6 = CLR  TR1 SETB TCON.6 = SETB TR1 For timer 1 CLR  TCON.5 = CLR  TF0 SETB TCON.5 = SETB TF0 CLR  TCON.4 = CLR  TR0 SETB TCON.4 = SETB TR0 For timer 0 TF1 IT0 IE0 IT1 IE1 TR0 TF0 TR1
Simple applications using ports &Timers Using a port ,by a simple program you can generate a Square wave of any duty cycle. HERE   :  SETB  P1.0  (Make bit of Port 0 High) LCALL DELAY CLR P1.0 LCALL DELAY SJMP  HERE  : Keep doing it Here same delay is used for both  High & low
Square-wave of 66%duty cycle. HERE   : SETB  P1.0  ( Make bit of Port 0 High) LCALL DELAY LCALL DELAY CLR  P1.0 LCALL DELAY SJMP HERE  : Keep doing it
Square-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 COMMUNICATION
Basics of serial communication
Types of Serial communications
RxD and TxD pins in the 8051 The 8051 has two pins for transferring and receiving data by serial communication. These two pins are part of the Port3(P3.0 &P3.1) These pins are TTL compatible and hence they require a line driver to make them RS232 compatible  Max232 chip is one such line driver in use.  Serial communication is controlled by an 8-bit register called SCON register,it is a bit addressable register.
Interfacing to PC
SCON (Serial control) register
SM0 , SM1 These two bits of SCON register determine the framing of data by specifying the number of bits per character 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
REN ,  TI ,   RI REN (Receive Enable) also referred as  SCON.4 . When it is high,it allows the 8051 to receive data on the RxD pin. So to receive and transfer data REN must be set to 1.When REN=0,the receiver is disabled. This is achieved as below  SETB  SCON.4 &  CLR  SCON.4
Contd… TI (Transmit interrupt) is the D1 bit of SCON register. When 8051 finishes the transfer of 8-bit character, it raises the TI flag to indicate that it is ready to transfer another  byte. The TI bit is raised at the beginning of the stop bit.  RI (Receive interrupt) is the D0 bit of the SCON register. When the 8051 receives data serially ,via RxD, it gets rid of the start and stop bits and places the byte in the SBUF register.Then it raises the RI flag bit to indicate that a byte has been received and should be picked up before it is lost.RI is raised halfway through the stop bit.
8051 Interrupts An  interrupt  is an external or internal event that  disturbs the  microcontroller to inform it that a device needs its service. A  M icrocontroller can serve  various  devices. Th ere  are two ways to do that: interrupts  & polling. The program which is associated with the interrupt is called the  interrupt service routine  (ISR) or  interrupt handler .
Steps in executing an interrupt Upon receiving the interrupt signal the Microcontroller , f inish  current  instruction and s a ves the PC on stack. J umps to a fixed location in memory  depending on type of interrupt S tarts to execute the interrupt service routine until RETI (return from interrupt) Upon executing the RETI the microcontroller returns to the place where it was interrupted. Get  pop  PC from stack
Interrupt Sources Original 8051 has 6 sources of interrupts Reset  Timer 0 overflow Timer 1 overflow External Interrupt 0 External Interrupt 1 Serial Port events (buffer full, buffer empty, etc) Enhanced version has 22 sources More timers, programmable counter array, ADC, more external interrupts, another serial port (UART)
Each interrupt has a specific place in code memory where program execution (interrupt service routine) begins. External Interrupt 0:  0003h Timer 0 overflow:  000Bh External Interrupt 1: 0013h Timer 1 overflow:  001Bh Serial :  0023h Timer 2 overflow (8052+)  002bh Interrupt Vectors
Interrupt 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 same time? The interrupt with the highest PRIORITY gets serviced first. All interrupts have a power on default priority order.  External interrupt 0 (INT0) Timer interrupt0 (TF0) External interrupt 1 (INT1) Timer interrupt1 (TF1) Serial communication (RI+TI) Priority can also be set to “high” or “low” by IP reg. Interrupt Priorities
Interrupt Priorities (IP) Register IP.7: reserved IP.6: reserved IP.5: Timer 2 interrupt priority bit (8052 only) IP.4: Serial port interrupt priority bit IP.3: Timer 1 interrupt priority bit IP.2: External interrupt 1 priority bit IP.1: Timer 0 interrupt priority bit IP.0: External interrupt 0 priority bit --- PX0 PT0 PX1 PT1 PS PT2 ---
Interrupt Priorities Example MOV IP , #00000100B   or   SETB IP.2   gives priority order Int1 Int0 Timer0 Timer1 Serial MOV IP , #00001100B   gives priority order Int1 Timer1 Int0 Timer0 Serial --- PX0 PT0 PX1 PT1 PS PT2 ---
Interrupt inside an interrupt A high-priority interrupt can interrupt a low-priority interrupy All interrupt are latched internally Low-priority interrupt wait until 8051 has finished servicing the high-priority interrupt --- PX0 PT0 PX1 PT1 PS PT2 ---
Applications of  Microcontrollers
Simple Interfacing Examples
Seven segment Interfacing
Traffic light controller
 
Closed loop control system-Temperature control example
 
 
 
 
 
 
 
 
Recent Wonders
Recent Wonders  contd ........
Recent Wonders  contd ........
Books that have helped me to understand the Microcontrollers & embedded systems  Barr, Michael, Programming embedded sytems in C and C++ - OReilly Publ. Raj Kamal, Embedded systems,  TMG Mazidi and Mazidi, The 8051 microcontroller and embedded sytems - Pearson education. Peatman,J.B. Design with microcontrollers and microcomputers, McGraw Hil
5)  Sewart. J.W. The 8051 Microcontroller Hardware, Software and Interfacing – Prentice Hall  6)   Ayala Kenneth, The 8051 Microntroller – Architecture, Programming and Applications – Delmar Publ. 7)   Ajay Deshmukh, Microcontrollers – TATA McGraw Hill 8)   Rajkamal, Microcontrollers - Architecture, Programming – Pearson Publ. 9)   Myke Predko, Programming the 8051 Microcontroller – McGraw Hill 10)   Michael J. Pont, Embedded C -  Addison Wesely Publ.
Useful websites
Useful websites  contd… http://www.eg3.com http://www.ARM.MCU.com http://www.mcjournal.com http://www.iar.com http:// http://www.embedded.com http://www.powersoftsystems.com
Epilogue 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 (20)

PDF
I2C Bus (Inter-Integrated Circuit)
Varun Mahajan
 
PPTX
Microprocessor 8086
Gopikrishna Madanan
 
PPT
Architecture of 8051 microcontroller))
Ganesh Ram
 
PDF
8051 microcontroller
Gaurav Verma
 
PPTX
Instruction Set of 8051 Microcontroller
Multisoft Virtual Academy
 
PPT
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )
Tarun Khaneja
 
PDF
8051 interfacing
KanchanPatil34
 
PDF
Introduction to ARM LPC2148
Veera Kumar
 
PDF
01 GPIO||General Purpose Input Output.2016
Mohamed Fawzy
 
PDF
8051 Architecture and PIN Configuration.pdf
Srikrishna Thota
 
PPTX
Switches and LEDs interface to the 8051 microcontroller
University of Technology - Iraq
 
PPTX
8251 USART
coolsdhanesh
 
PDF
Timer And Counter in 8051 Microcontroller
Jay Makwana
 
PPT
Memory & I/O interfacing
deval patel
 
PPTX
Interrupts of microprocessor 8085
mujeebkhanelectronic
 
PPTX
I/O Ports
Islam Samir
 
PPTX
5.programmable interval timer 8253
MdFazleRabbi18
 
PPT
Interfacing 8255
Anuja Bhakuni
 
PPT
Interrupt programming with 8051 microcontroller
Ankit Bhatnagar
 
PPTX
Data transfer techniques 8085
ShivamSood22
 
I2C Bus (Inter-Integrated Circuit)
Varun Mahajan
 
Microprocessor 8086
Gopikrishna Madanan
 
Architecture of 8051 microcontroller))
Ganesh Ram
 
8051 microcontroller
Gaurav Verma
 
Instruction Set of 8051 Microcontroller
Multisoft Virtual Academy
 
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )
Tarun Khaneja
 
8051 interfacing
KanchanPatil34
 
Introduction to ARM LPC2148
Veera Kumar
 
01 GPIO||General Purpose Input Output.2016
Mohamed Fawzy
 
8051 Architecture and PIN Configuration.pdf
Srikrishna Thota
 
Switches and LEDs interface to the 8051 microcontroller
University of Technology - Iraq
 
8251 USART
coolsdhanesh
 
Timer And Counter in 8051 Microcontroller
Jay Makwana
 
Memory & I/O interfacing
deval patel
 
Interrupts of microprocessor 8085
mujeebkhanelectronic
 
I/O Ports
Islam Samir
 
5.programmable interval timer 8253
MdFazleRabbi18
 
Interfacing 8255
Anuja Bhakuni
 
Interrupt programming with 8051 microcontroller
Ankit Bhatnagar
 
Data transfer techniques 8085
ShivamSood22
 

Similar to Microcontroller 8051 (20)

PPT
Microcontroller-8051.ppt
KalaiSelvan911913
 
PPT
Microcontroller-8051.ppt
Dr.YNM
 
PPT
Microcontroller 8051
Shivashankar Sawalgi
 
PPTX
Unit two and unit three pptx for btech ece
merabapudc
 
PDF
Architecture and Programmingpart1_Microcontroller
ssuser1bfdb5
 
PDF
microcontroller 8051 17.07.2023.pdf
818Farida
 
PPT
Mcu51
EngrShoaib
 
PPTX
MPMC UNIT II edited . ppt X and communication
srik38114
 
PPT
8051 microcontroller and it’s interface
Abhishek Choksi
 
PPT
microcontroller-8051-ppt(1)
jhcid
 
PPT
microcontroller-8051-ppt
jhcid
 
PPT
Microcontroller 8051
John Williams
 
PPTX
Microcontroller 8051 features and applications
anushkayadav3011
 
PPTX
Microcontroller (8051) by K. Vijay Kumar
Vijay Kumar
 
PPTX
8051 microcontroller by K. Vijay Kumar
Vijay Kumar
 
PPTX
8051 microcontroller features
Tech_MX
 
PPT
8051 Presentation
Sayan Chakraborty
 
PPT
janakiraman egsp collage I msc 4 unit
janakiramang6
 
Microcontroller-8051.ppt
KalaiSelvan911913
 
Microcontroller-8051.ppt
Dr.YNM
 
Microcontroller 8051
Shivashankar Sawalgi
 
Unit two and unit three pptx for btech ece
merabapudc
 
Architecture and Programmingpart1_Microcontroller
ssuser1bfdb5
 
microcontroller 8051 17.07.2023.pdf
818Farida
 
Mcu51
EngrShoaib
 
MPMC UNIT II edited . ppt X and communication
srik38114
 
8051 microcontroller and it’s interface
Abhishek Choksi
 
microcontroller-8051-ppt(1)
jhcid
 
microcontroller-8051-ppt
jhcid
 
Microcontroller 8051
John Williams
 
Microcontroller 8051 features and applications
anushkayadav3011
 
Microcontroller (8051) by K. Vijay Kumar
Vijay Kumar
 
8051 microcontroller by K. Vijay Kumar
Vijay Kumar
 
8051 microcontroller features
Tech_MX
 
8051 Presentation
Sayan Chakraborty
 
janakiraman egsp collage I msc 4 unit
janakiramang6
 
Ad

Recently uploaded (20)

PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPTX
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PPTX
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PPTX
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
Ad

Microcontroller 8051

  • 1. MICROCONTROLLER-8051 Features & Applications Dr. Y .Narasimha Murthy Ph.D., Sri Saibaba National College (Autonomous) ANANTAPUR-515001(A.P)
  • 2. … .. Man’s glory lies in his knowledge, his upright conduct, his praise-worthy character, his wisdom, and not in his nationality or rank --Baha’ullah (From, the book The 8051 Microcontroller and Embedded systems- Mazidi )
  • 3. Overview Introduction Block Diagram and Pin Description of the 8051 Registers Memory mapping in 8051 Stack in the 8051 I/O Port Programming Timers Interrupts & Applications
  • 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 learn Microcontrollers ?
  • 5. Personal information products: Cell phone, pager, watch, pocket recorder, calculator Laptop components: mouse, keyboard, modem, fax card, sound card, battery charger Home appliances: door lock, alarm clock, thermostat, air conditioner, TV remote, VCR, small refrigerator, exercise equipment, washer/dryer, microwave oven Industrial equipment: Temperature/pressure controllers, Counters, timers, RPM Controllers 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 ????
  • 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 a 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. EVOLUTION Flashback !!!! In the year 1976, Motorola created a Microprocessor chip called 6801 which replaced its brother 6800 with certain add-on chips to make a computer. This paved the way for the new revolution in the history of chip design and gave birth to a new entity called MICROCONTROLLER. The INTEL bagged the credit of producing the first Microcontroller 8048 with a CPU and 1K bytes of EPROM, 64 Bytes of RAM an 8-Bit Timer and 27 I/O pins in 1976.
  • 11. Evolution contd … Then followed the most popular controller 8051 in the year 1980 with 4K bytes of ROM,128 Bytes of RAM , a serial port, two 16-bit Timers , and 32 I/O pins. The 8051 family has many additions and improvements over the years and remains a most soughtafter tool for todays circuit designers. The same INTEL introduced a 16 bit controller 8096 in the year 1982
  • 12. Later INTEL introduced 80c196 series of 16-bit microcontrollers for mainly industrial applications Microchip, another company has introduced a microcontroller PIC 16C64 an 8-bit in the year 1985 . 32-bit microcontrollers have been developed by IBM and Motorola-MPC 505 is a 32-bit RISC controller of Motorola The 403 GA is a 32 -bit RISC embedded controller of IBM
  • 13. ARM Controllers In recent times ARM company (Advanced Risc machines) has developed and introduced 32 bit controllers which are highend application devices,especially communication devices like mobiles , ipods etc..(Refer www.arm.com)
  • 14. Types of Microcontrollers
  • 15. Microcontrollers 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 Microcontollers Feature 8031 8051 8052 8751 ROM NO 4kB 8kB 4kB UV Eprom RAM (Bytes) 128 128 256 128 TIMERS 2 2 3 2 I/O PINS 32 32 32 32 SERIAL PORTS 1 1 1 1 INTERRUPT 6 6 8 6 SOURCES
  • 17. Microcontroller 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 2 n
  • 18. Important Features of 8051 4K bytes ROM 128 bytes RAM Four 8-bit I/O ports Two 16-bit timers Serial interface 64K external code memory space 64K data memory space
  • 19. “Original” 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. The 8051 is a 40 pin device, but out of these 40 pins, 32 are used for I/O. 24 of these are dual purpose, i.e. they can operate as I/O or a control line or as part of address or date bus. Pin Description of the 8051
  • 21. 8051 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 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 Registers (*Denotes the SFRs)
  • 26. Memory mapping in 8051 ROM memory map in 8051 family 4k DS5000-32 8k 32k from Atmel Corporation from Dallas Semiconductor 0000H 0FFFH 0000H 1FFFH 0000H 7FFFH 8051 8752
  • 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 8051 8051 has 4 Ports. Port 0, Port1, Port2 , Port3 Port 0 is a dual purpose port, it is located from pin 32 to pin 39 (8 pins). To use this port as both input/output ports each pin must be connected externally to a 10 k ohm pull-up resistor.This is because Port 0 is an open drain. Simple ex: MOV A, #22 BACK MOV P0 ,A ACALL DELAY CPL A SJMP BACK
  • 29. Port 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 21 through 28) It can be used for general I/O or as the high byte of the address bus for designs with external code memory .Like P1 ,Port2 also doesn’t require any pull-up resistors Ports….
  • 31. Ports contd… Port 3 is also dual purpose but designers generally avoid using this port unnecessarily for I/O because the pins have alternate functions which are related to special features of the 8051. Indiscriminate use of these pins may interfere with 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)
  • 33. I/O Port structure The internal circuitry for the I/O port is shown in the next slide If you want to read in from a pin, you must first give a logic ‘1’ to the port latch to turn off the FET otherwise the data read in will always be logic ‘0’. When you write to the port you are actually writing to the latch e.g. a logic 0 given to the latch will be inverted and turn on the FET which cause the port pin to be connected to Gnd (logic 0).
  • 35. Timers /Counters The 8051 has 2 timers/counters: Timer/Counter 0 Timer/Counter 1 They can be used as The Timer :Uused as a time delay generator. The clock source is the internal crystal frequency of the 8051. An event counter . External input from input pin to count the number of events on registers. These clock pulses cold represent the number of people passing through an entrance, or the number of wheel rotations, or any other event that can be converted to pulses.
  • 36. Timer Set the initial value of registers Start the timer and then the 8051 counts up. Input from internal system clock (machine cycle) When the registers equal to 0 and the 8051 sets a bit to denote time out to LCD P1 8051 TL0 TH0 P2 Set Timer 0
  • 37. Counter Count the number of events Show the number of events on registers External input from T0 input pin (P3.4) for Counter 0 External input from T1 input pin (P3.5) for Counter 1 External input from Tx input pin. We use Tx to denote T0 or T1. T0 to LCD P3.4 P1 8051 a switch TL0 TH0
  • 38. Registers Used in Timer/Counter 8051 has two 16-bit Timer registers ,Timer 0 & Timer 1. As 8051 has 8-bit architecture , each Timer register is treated as two 8-bit registers namely TH0, TL0, TH1, TL1. One 8-bit mode register -TMOD. One 8-bit control register-TCON.
  • 39. TMOD Register Both Timer 0 &Timer 1 use the same Mode register TMOD. It is an-8-bit register .The lower 4-bits are meant for Timer 0 &the uooer 4-bits are meant for Timer 1 It is not bit addressible. It is used similar to any other register of 8051 . For ex: MOV TMOD,#21H GATE C/T M1 M0 GATE C/T M1 M0 Timer 1 Timer 0 (MSB) (LSB)
  • 40. Gate Every timer has a mean of starting and stopping. GATE=0 Internal control The start and stop of the timer are controlled by way of software. Set/clear the TR for start/stop timer. SETB TR0 CLR TR0 GATE=1 External control The hardware way of starting and stopping the timer by software and an external source . Timer/counter is enabled only while the INT pin is high and the TR control pin is set (TR).
  • 41. TMod contd…. C/T : Timer or counter selected cleared for timer operation (input from internal system clock). Set for counter operation (input from Tx input pin). M1,M0 : Used for mode selection.Because the Timers of 8051 can be set in 4-different modes. M1 M0 Mode Operation 0 0 0 1 3-bit timer mode 8-bit THx + 5-bit TLx (x= 0 or 1) 0 1 1 16-bit timer mode 8-bit THx + 8-bit TLx 1 0 2 8-bit auto reload 8-bit auto reload timer/counter; THx holds a value which is to be reloaded into TLx each time it overflows. 1 1 3 Split timer mode
  • 43. Let us understand the working of Timer Mode 1 For this , let us consider timer 0 as an example. 16-bit timer (TH0 and TL0) TH0-TL0 is incremented continuously when TR0 is set to 1. And the 8051 stops to increment TH0-TL0 when TR0 is cleared. The timer works with the internal system clock. In other words, the timer counts up each machine cycle. When the timer (TH0-TL0) reaches its maximum of FFFFH, it rolls over to 0000, and TF0 is raised. Programmer should check TF0 and stop the timer 0.
  • 44. Steps of Mode 1 Choose mode 1 timer 0 MOV TMOD,#01H Set the original value to TH0 and TL0. MOV TH0,#FFH MOV TL0,#FCH You better to clear the TF: TF0=0. CLR TF0 Start the timer. SETB TR0
  • 45. Mode 1 contd… The 8051 starts to count up by incrementing the TH0-TL0 . TH0-TL0= FFFCH,FFFDH,FFFEH,FFFFH,0000H TF = 0 TF = 0 TF = 0 TF = 0 TF = 1 TH0 TL0 Start timer Stop timer Monitor TF until TF=1 TR0=1 TR0=0 TF FFFC FFFD FFFE FFFF 0000
  • 46. Mode 1 contd… When TH0-TL0 rolls over from FFFFH to 0000, the 8051 set TF0=1. TH0-TL0= FFFE H, FFFF H, 0000 H (Now TF0=1) Keep monitoring the timer flag (TF) to see if it is raised. AGAIN: JNB TF0, AGAIN Clear TR0 to stop the process. CLR TR0 Clear the TF flag for the next round. CLR TF0
  • 47. TCON 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… 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 Timer Control Register TCON: Timer/Counter Control Register CLR TCON.7 = CLR TF1 SETB TCON.7 = SETB TF1 CLR TCON.6 = CLR TR1 SETB TCON.6 = SETB TR1 For timer 1 CLR TCON.5 = CLR TF0 SETB TCON.5 = SETB TF0 CLR TCON.4 = CLR TR0 SETB TCON.4 = SETB TR0 For timer 0 TF1 IT0 IE0 IT1 IE1 TR0 TF0 TR1
  • 50. Simple applications using ports &Timers Using a port ,by a simple program you can generate a Square wave of any duty cycle. HERE : SETB P1.0 (Make bit of Port 0 High) LCALL DELAY CLR P1.0 LCALL DELAY SJMP HERE : Keep doing it Here same delay is used for both High & low
  • 51. Square-wave of 66%duty cycle. HERE : SETB P1.0 ( Make bit of Port 0 High) LCALL DELAY LCALL DELAY CLR P1.0 LCALL DELAY SJMP HERE : Keep doing it
  • 52. Square-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
  • 54. Basics of serial communication
  • 55. Types of Serial communications
  • 56. RxD and TxD pins in the 8051 The 8051 has two pins for transferring and receiving data by serial communication. These two pins are part of the Port3(P3.0 &P3.1) These pins are TTL compatible and hence they require a line driver to make them RS232 compatible Max232 chip is one such line driver in use. Serial communication is controlled by an 8-bit register called SCON register,it is a bit addressable register.
  • 59. SM0 , SM1 These two bits of SCON register determine the framing of data by specifying the number of bits per character 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. REN , TI , RI REN (Receive Enable) also referred as SCON.4 . When it is high,it allows the 8051 to receive data on the RxD pin. So to receive and transfer data REN must be set to 1.When REN=0,the receiver is disabled. This is achieved as below SETB SCON.4 & CLR SCON.4
  • 61. Contd… TI (Transmit interrupt) is the D1 bit of SCON register. When 8051 finishes the transfer of 8-bit character, it raises the TI flag to indicate that it is ready to transfer another byte. The TI bit is raised at the beginning of the stop bit. RI (Receive interrupt) is the D0 bit of the SCON register. When the 8051 receives data serially ,via RxD, it gets rid of the start and stop bits and places the byte in the SBUF register.Then it raises the RI flag bit to indicate that a byte has been received and should be picked up before it is lost.RI is raised halfway through the stop bit.
  • 62. 8051 Interrupts An interrupt is an external or internal event that disturbs the microcontroller to inform it that a device needs its service. A M icrocontroller can serve various devices. Th ere are two ways to do that: interrupts & polling. The program which is associated with the interrupt is called the interrupt service routine (ISR) or interrupt handler .
  • 63. Steps in executing an interrupt Upon receiving the interrupt signal the Microcontroller , f inish current instruction and s a ves the PC on stack. J umps to a fixed location in memory depending on type of interrupt S tarts to execute the interrupt service routine until RETI (return from interrupt) Upon executing the RETI the microcontroller returns to the place where it was interrupted. Get pop PC from stack
  • 64. Interrupt Sources Original 8051 has 6 sources of interrupts Reset Timer 0 overflow Timer 1 overflow External Interrupt 0 External Interrupt 1 Serial Port events (buffer full, buffer empty, etc) Enhanced version has 22 sources More timers, programmable counter array, ADC, more external interrupts, another serial port (UART)
  • 65. Each interrupt has a specific place in code memory where program execution (interrupt service routine) begins. External Interrupt 0: 0003h Timer 0 overflow: 000Bh External Interrupt 1: 0013h Timer 1 overflow: 001Bh Serial : 0023h Timer 2 overflow (8052+) 002bh Interrupt Vectors
  • 66. Interrupt 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 same time? The interrupt with the highest PRIORITY gets serviced first. All interrupts have a power on default priority order. External interrupt 0 (INT0) Timer interrupt0 (TF0) External interrupt 1 (INT1) Timer interrupt1 (TF1) Serial communication (RI+TI) Priority can also be set to “high” or “low” by IP reg. Interrupt Priorities
  • 70. Interrupt Priorities (IP) Register IP.7: reserved IP.6: reserved IP.5: Timer 2 interrupt priority bit (8052 only) IP.4: Serial port interrupt priority bit IP.3: Timer 1 interrupt priority bit IP.2: External interrupt 1 priority bit IP.1: Timer 0 interrupt priority bit IP.0: External interrupt 0 priority bit --- PX0 PT0 PX1 PT1 PS PT2 ---
  • 71. Interrupt Priorities Example MOV IP , #00000100B or SETB IP.2 gives priority order Int1 Int0 Timer0 Timer1 Serial MOV IP , #00001100B gives priority order Int1 Timer1 Int0 Timer0 Serial --- PX0 PT0 PX1 PT1 PS PT2 ---
  • 72. Interrupt inside an interrupt A high-priority interrupt can interrupt a low-priority interrupy All interrupt are latched internally Low-priority interrupt wait until 8051 has finished servicing the high-priority interrupt --- PX0 PT0 PX1 PT1 PS PT2 ---
  • 73. Applications of Microcontrollers
  • 77.  
  • 78. Closed loop control system-Temperature control example
  • 79.  
  • 80.  
  • 81.  
  • 82.  
  • 83.  
  • 84.  
  • 85.  
  • 86.  
  • 88. Recent Wonders contd ........
  • 89. Recent Wonders contd ........
  • 90. Books that have helped me to understand the Microcontrollers & embedded systems Barr, Michael, Programming embedded sytems in C and C++ - OReilly Publ. Raj Kamal, Embedded systems, TMG Mazidi and Mazidi, The 8051 microcontroller and embedded sytems - Pearson education. Peatman,J.B. Design with microcontrollers and microcomputers, McGraw Hil
  • 91. 5) Sewart. J.W. The 8051 Microcontroller Hardware, Software and Interfacing – Prentice Hall 6) Ayala Kenneth, The 8051 Microntroller – Architecture, Programming and Applications – Delmar Publ. 7) Ajay Deshmukh, Microcontrollers – TATA McGraw Hill 8) Rajkamal, Microcontrollers - Architecture, Programming – Pearson Publ. 9) Myke Predko, Programming the 8051 Microcontroller – McGraw Hill 10) Michael J. Pont, Embedded C - Addison Wesely Publ.
  • 93. Useful websites contd… http://www.eg3.com http://www.ARM.MCU.com http://www.mcjournal.com http://www.iar.com http:// http://www.embedded.com http://www.powersoftsystems.com
  • 94. Epilogue 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

  • #20: Program memory – RAM or ROM? Data memory – RAM or ROM?