e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

Similar documents
8051 Microcontrollers

Module I. Microcontroller can be classified on the basis of their bits processed like 8bit MC, 16bit MC.

8051 microcontrollers

EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 4 The 8051 Architecture

Microcontrollers. Fig. 1 gives a comparison of a microprocessor system and a microcontroller system.

UNIT 5. Microcontrollers. Syllabus

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

UNIT IV MICROCONTROLLER

8051 Microcontroller

THE 8051 MICROCONTROLLER Simple comparison: Pentium vs. 8051

8051 MICROCONTROLLER


8051 Microcontroller

Memory Organization. Program Memory

ENE 334 Microprocessors

Embedded World Television, Radio, CD player, Washing Machine Microwave Oven Card readers, Palm devices

Lecture 1. Course Overview and The 8051 Architecture

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT89S52

MICROPROCESSORS AND MICROCONTROLLERS MATERIAL. Features of 8051:

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI

Three criteria in Choosing a Microcontroller

MICROCONTROLLER AND PLC LAB-436 SEMESTER-5

Question Bank Microprocessor and Microcontroller

8051 Microcontroller memory Organization and its Applications

UNIT V MICRO CONTROLLER PROGRAMMING & APPLICATIONS TWO MARKS. 3.Give any two differences between microprocessor and micro controller.

CS 320. Computer Architecture Core Architecture

EE6502- MICROPROCESSOR AND MICROCONTROLLER

Serial I-O for Dinesh K. Sharma Electrical Engineering Department I.I.T. Bombay Mumbai (version 14/10/07)

Rev. No. History Issue Date Remark

8051 MICROCONTROLLER

Architecture of 8085 microprocessor

MODULE-1. Short Answer Questions

EXPERIMENT NO.1. A Microcontroller is a complete computer system built on a single chip.

1. Pin diagram of 8051 and ports

ISSI. IS89C51 CMOS SINGLE CHIP 8-BIT MICROCONTROLLER with 4-Kbytes of FLASH ISSI IS89C51 NOVEMBER 1998 FEATURES GENERAL DESCRIPTION

8/26/2010. Introduction to 8085 BLOCK DIAGRAM OF INTEL Introduction to Introduction to Three Units of 8085

12-Dec-11. Gursharan Singh Maninder Kaur. Introduction to 8085 BLOCK DIAGRAM OF INTEL Introduction to Introduction to 8085

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

Microcomputer Architecture and Programming

1. INTRODUCTION TO MICROPROCESSOR AND MICROCOMPUTER ARCHITECTURE:

UNIT MICROCONTROLLER AND ITS PROGRAMMING

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Serial Port Communication Module No: CS/ES/11 Quadrant 1 e-text

SYLLABUS UNIT - I 8086/8088 ARCHITECTURE AND INSTRUCTION SET

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interfacing External Devices using Embedded C Module No: CS/ES/22


Moodle WILLINGDON COLLEGE SANGLI (B. SC.-II) Digital Electronics

MCS-51 Serial Port A T 8 9 C 5 2 1

The Timers/Counters The Serial Interface The Interrupt System Reset P0.0-P0.7 P2.0-P2.7. Port 2 Drivers. Port 2 Latch

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples.

Architecture and Programming of 8051 Microcontrollers

Introduction To MCS-51

8051 Overview and Instruction Set

Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

CHAPTER 5 : Introduction to Intel 8085 Microprocessor Hardware BENG 2223 MICROPROCESSOR TECHNOLOGY

Introducing The MCS 251 Microcontroller -- 8XC251SB

Microprocessors/Microcontrollers

8051 Microcontrollers

8051 Microcontroller Interrupts

SH57K12. High Performance 8031 Microcontroller. Preliminary. Features. General Description

Unit I. Introduction Microcontrollers and Embedded processors Overview of the 8051 Inside the 8051 Addressing Modes

CoE3DJ4 Digital Systems Design. Chapter 5: Serial Port Operation

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

1 MALP ( ) Unit-1. (1) Draw and explain the internal architecture of 8085.

MSM80C154S MSM83C154S MSM85C154HVS USER'S MANUAL

Microprocessor Architecture

History and Basic Processor Architecture

8051 Serial Communication

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Serial Port Programming in Assembly Module No: CS/ES/12 Quadrant 1 e-text

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI UNIT- IV

Microcontroller and Embedded Systems:

CONSUMER ELECTRONICS Microwave Ovens

Sencer Yeralan and Helen Emery Gainesville, Florida January 2000

Chapter 1: Basics of Microprocessor [08 M]

Module Contents of the Module Hours COs

INTEGRATED CIRCUITS DATA SHEET. P89C738; P89C739 8-bit microcontrollers Dec 15. Product specification File under Integrated Circuits, IC20

Microcontroller & Interfacing

1. Internal Architecture of 8085 Microprocessor

8051 Timers and Serial Port

Microcontrollers can be considered as self-contained systems with a processor, memory and I/O ports.

MICROCONTROLLER UNIT 1

The functional block diagram of 8085A is shown in fig.4.1.

C511/C511A C513/C513A C513A-H 8-Bit CMOS Microcontroller. User s Manual Semiconductor/

Handshake Solutions. HT80C51 User Manual

8XC51RA RB RC Hardware Description

ELEG3924 Microprocessor

MICROPROCESSOR MICROPROCESSOR. From the above description, we can draw the following block diagram to represent a microprocessor based system: Output

Engr. A. N. Aniedu Electronic and Computer Engineering Nnamdi Azikiwe University, Awka

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text

ELEG3923 Microprocessor Ch.2 Assembly Language Programming

b. List different system buses of 8085 microprocessor and give function of each bus. (8) Answer:

CHAPTER 1 MICROCOMPUTER SYSTEMS. 1.1 Introduction. 1.2 Microcontroller Evolution

UNIT MICROCONTROLLER

AVR Microcontrollers Architecture

DQ8051. Revolutionary Quad-Pipelined Ultra High performance 8051 Microcontroller Core

3. (a) Explain the steps involved in the Interfacing of an I/O device (b) Explain various methods of interfacing of I/O devices.

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interrupt Programming in Embedded C Module No: CS/ES/20 Quadrant 1 e-text

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI UNIT I THE 8085 & 8086 MICROPROCESSORS. PART A (2 Marks)

1. Internal Architecture of 8085 Microprocessor

Control Unit: The control unit provides the necessary timing and control Microprocessor resembles a CPU exactly.

Transcription:

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text In this lecture the detailed architecture of 8051 controller, register bank, special purpose registers, timers and memory elements of 8051 will be discussed. 1. 8051 Micro controller The Microcontroller incorporates all the features that are found in microprocessor. It has built in ROM, RAM, Input Output ports, Serial Port, timers, interrupts and clock circuit. Microcontroller (MC) may be called computer on chip since it has basic features within single chip. These are usually dedicated devices embedded within an application. For example, microcontrollers are used as engine controllers in automobiles and as exposure and focus controllers in cameras. The I/O, memory, and on-chip peripherals of a microcontroller are selected depending on the specifics of the target application. Since microcontrollers are powerful digital processors, the degree of control and programmability they provide significantly enhances the effectiveness of the application. The 8051 is the first microcontroller of the MCS-51 family introduced by Intel Corporation at the end of the 1970s. The microcontroller has on chip peripheral devices. This is widely used in washing machines, vcd player, microwave oven, robotics or in industries. Microcontroller can be classified on the basis of their bits processed like 8bit MC, 16bit MC. 8 bit microcontroller, means it can read, write and process 8 bit data. Ex. 8051 microcontroller. Basically 8 bit specifies the size of data bus. 8 bit microcontroller means 8 bit data can travel on the data bus or we can read, write process 8 bit data. 1.1 8051 Architecture 8051 micro controller is an 8 bit controller. Figure 1.1 shows the architecture diagram of 8051. The 8051 microcontroller has the following features: 4 Kb of ROM. 128b of RAM (including SFRs) satisfies the user's basic needs. 4 ports, each having 8 input/ouput lines, total of 32 input/output lines are present which are sufficient to make all necessary connections to peripheral environment. It has Accumulator, general purpose registers and special purpose registers and It has ALU which does all kind of arithmetic and logical operations.

Figure 1.1 Architecture of 8051 The whole configuration is obviously thought of as to satisfy the needs of most programmers working on development of automation devices. One of its advantages is that nothing is missing and nothing is too much. In other words, it is created exactly in accordance to the average user s taste and needs. Another advantages are RAM organization, the operation of Central Processor Unit (CPU) and ports which completely use all recourses and enable further upgrades. Further it has eight general purpose registers namely R0, R1, R2, R3, R4, R5, R6, R7. All are 8 bit wide and used as scratch pad. R0 and R1 are used as pointers in indirect addressing mode. Accumulator is a very important register in 8051. In this figure ACC is the Accumulator register. It is referred as A. It is holding one operand in arithmetic and logical instructions and 8 bit wide. Next important register is B Register. The B register is used during multiply and divide operations for other instructions it can be treated as another scratch pad register and 8 bit length. During program execution Program counter (PC) plays vital role. It is 16 bit length. Holds address of the instruction to be execute next. It has many special purpose registers like PSW, TMOD, SBUF etc. 1.2 Program Status Word (PSW) (MSB) (LSB) CY AC F0 RS1 RS0 OV - P

PSW (Fig 1.2) is a special purpose register. It is 8-bit wide. The PSW register contains program status information execution. It shows the carry Flag and auxiliary carry flag and Symbol Position Name and significance CY PSW 7 Carry flag AC PSW 6 Auxillary carry flag ( For BCD Operations) F0 PSW 5 Flag 0 (Available to the user for general purposes) RS1 PSW 4 Register bank select control bits 1 & 0. Set/Cleared by software to determine working register bank(see Note). RS0 PSW 3 ov PSW 2 Overflow flag - PSW 1 (reserved) P PSW 0 Parity flag Set/cleared by hardware each instruction cycle to indicate and odd/even number of "one" bits in the accumulator,i.e., even parity Note: The contents of (RS1,RS0) enable the working banks as follows (0,0)- Bank 0(00H-07H) (0,1)- Bank 1(08H-0FH) (1,0)- Bank 2(10-17H) (1,1)- Bank 3(18H-1FH) F Figure 1.2 PSW overflow flag to indicate these information during program execution. If the MSB bit CY is 1, then it indicates there is presence of carry that arrives during processing. While doing the addition of two numbers and if there is overflow in the fourth bit, then the Auxillary carry becomes 1. When a data is processed and the result obtained is zero, then Flag F0 is set as 1.Registers memory address also shown via RS0 and RS1 bits. OV is the Overflow flag. parity flag indicated parity status, this bit is 1 based on odd and even parity. 1.3 Stack Pointer The Stack Pointer register is 8 bits wide. It indicates the address of the stack. It is incremented before data is stored during PUSH and CALL executions. It may reside anywhere in on-chip RAM. The Stack Pointer is initialized to 07H after a reset. This causes the stack to begin at location 08H. 1.4 Data Pointer The Data Pointer (DPTR) consists of two registers namely high byte (DPH) and a low byte (DPL). Its intended function is to hold a 16-bit address. It may be manipulated as a 16-bit register or as two independent 8-bit registers. This register pair is used as a pointer for addressing/accessing the external memory.

1.5 Ports 0 to 3 There are four parallel ports and two serial communication ports. Ports P0, P1, P2 and P3 are the SFR latches of Ports 0, 1, 2 and 3, respectively. Port 1 is a simple I/O port. Port 0 and Port 2 are simple I/O and address/data ports. These ports are used as multiplexed ports for address and data communication for external memory access. Port 3 is a simple I/O port and Multiple function assigned to each pins of this port. All 8051 microcontrollers have 4 I/O ports each comprising 8 bits which can be configured as inputs or outputs. Accordingly, in total of 32 input/output pins enabling the microcontroller to be connected to peripheral devices are available for use. Pin configuration, i.e. whether it is to be configured as an input (1) or an output (0), depends on its logic state. In order to configure a microcontroller pin as an output, it is necessary to apply a logic zero (0) to appropriate I/O port bit. In this case, voltage level on appropriate pin will be 0. Similarly, in order to configure a microcontroller pin as an input, it is necessary to apply a logic one (1) to appropriate port. In this case, voltage level on appropriate pin will be 5V (as is the case with any TTL input). This may seem confusing but don't loose your patience. It all becomes clear after studying simple electronic circuits connected to an I/O pin. 1.5.1 Port 1 P1 is a true I/O port, because it doesn't have any alternative functions as is the case with P0, but can be configured as general I/O only. It has a pull-up resistor built-in and is completely compatible with TTL circuits. 1.5.2 Port 2 P2 acts similarly to P0 when external memory is used. Pins of this port occupy addresses intended for external memory chip. This time it is about the higher address byte with addresses A8-A15. When no memory is added, this port can be used as a general input/output port showing features similar to P1. 1.5.3 Port 3 All port pins can be used as general I/O, but they also have an alternative function. In order to use these alternative functions, a logic one (1) must be applied to appropriate bit of the P3 register. In terms of hardware, this port is similar to P0, with the difference that its pins have a pull-up resistor built-in. 1.6 Serial Data Buffer (SBUF) Serial data buffer supports serial communication. It is actually two separate registers, one transmit buffer and one receive buffer register. When data is moved to SBUF, it goes to the transmit buffer where it is held for serial transmission. When data is moved from SBUF, it comes from the receive buffer. It acts as a interface between either transmitter or receiver to the processor.

1.7 Timer Registers Timer register pairs (TH0, TL0), (TH1,TL1), are the 16-bit counting registers for Timer/Counters 0, 1 respectively. This can be operated as 8 bit /13bit/16 bit timers. It counts the external negative transition also if it is configured as counter. 1.8 Control Registers Special Function Registers IP, IE, TMOD, TCON, SCON, and PCON contain control and status bits for the interrupt system, the timer/counters, and the serial port. When the system configured for interrupt based service then Interrupt Enable(IE) and TCON registers place major role. IE is set to 1 for enabling the system to work on interrupt. SCON is used during serial communication. TMOD is used during the timer/counter operation. These registers are used to support, enable and to activate different processes which can be handled by 8051 microcontroller. 1.9 Memory The 8051 has two types of memory and these are Program Memory and Data Memory. Program Memory (ROM) is used to permanently save the program being executed, while Data Memory (RAM) is used for temporarily storing data and intermediate results created and used during the operation of the microcontroller. Depending on the model in use, at most a few Kb of ROM and 128 or 256 bytes of RAM is used. However all 8051 microcontrollers have a 16- bit addressing bus and are capable of addressing 64 kb memory. It is neither a mistake nor a big ambition of engineers who were working on basic core development. It is a matter of smart memory organization which makes these microcontrollers a real programmers goody. 1.9.1 Data Memory (128 bytes) 8051 has only 128 bytes. It has been used effectively and optimally as given below (Fig 1.3). Figure 1.3 Data memory

Based on the bits (RS0, RS1) set at PSW register the register bank address is found from the memory. The address of the memory ranges from 00-7F and data is stored on it. If (RS0, RS1) is between 00-07,08-0F,10-17,18-1F (Fig 1.4) then the data is stored in register bank 0, bank 1, bank2 and bank3 respectively. If (RS0,RS1) is between 20-2F, it is called as Bitaddressable RAM. It is used to address data while doing processing. The major space from 30-7F is called as Scratch pad RAM in which all code can be moved here and the process can be done. Program status word is used to refer the location of the registers. Figure 1.4 Register bank and Address Figure 1.5 PSW bank selection If the program status word ( Fig 1.5) register (PSW.4, PSW.3) is (0,0) then the data is stored in bank 0, if it is (0,1), (1,0) and (1,1) then the data is stored in bank 1,bank 2 and bank3 respectively. External memory is interfaced through DPTR register. It has DPH and DPL register pair combined to form 16 bit word. 1.10 Arithmetic and Logic unit ( ALU ) Arithmetic and logic unit is a 8 bit unit. It performs arithmetic and logical operations. For doing addition operation minimum two operands are needed and one of the operand comes through the accumulator and other one comes through the temporary register. After the addition operation, data is send to another temporary register. For doing multiplication or division operation the operands are put in Accumulator and B register. It also performs

Increment/decrement register contents. Sometimes the PC values can be incremented or the data values can be decremented in the register. 1.11 Timers and counters The microcontroller oscillator uses quartz crystal for its operation. As the frequency of this oscillator is precisely defined and very stable, pulses are generated with same width, which makes them ideal for time measurement. Such crystals are also used in quartz watches. In order to measure time between two events it is sufficient to count up pulses coming from this oscillator. That is exactly what the timer does. If the timer is properly programmed, the value stored in its register will be incremented (or decremented) with each coming pulse, i.e. once per each machine cycle. A single machine-cycle instruction lasts for 12 quartz oscillator periods, which means that by embedding quartz with oscillator frequency of 12MHz, a number stored in the timer register will be changed million times per second, i.e. each microsecond. The 8051 microcontroller has 2 timers/counters called T0 and T1. As their names suggest, their main purpose is to measure time and count external events. Besides, they can be used for generating clock pulses to be used in serial communication, so called Baud Rate. 1.11.1 Clock circuit Figure 1.6 Clock Circuit 8051b has crystal oscillators (Fig 1.6) which generates the clock pulses. The oscillator, in any case, drives the internal clock generator, the clock generator provides the internal clocking signals to the chip. The internal clocking signals are at half the oscillator frequency, and define the internal phases, states, and machine cycles. External clocks can also be supported by the controller. Machine cycle consists of 12 oscillator periods So each work done by the controller in 1 machine cycle take 12 clock cycles.

2. Pinout Description Figure 2.1 Pin configuration Figure 2.1 shows the pin configuration of microcontroller 8051. Pins 1-8: Port1 Each of these pins can be configured as an input or an output. Pin 9: RS A logic one on this pin disables the microcontroller and clears the contents of most registers. In other words, the positive voltage on this pin resets the microcontroller. By applying logic zero to this pin, the program starts execution from the beginning. Pins10-17: Port 3 Similar to port 1, each of these pins can serve as general input or output. Besides, all of them have alternative functions. Pin 10: RXD Serial asynchronous communication input or Serial synchronous communication output. Pin 11: TXD Serial asynchronous communication output or Serial synchronous communication clock output. Pin 12: INT0 Interrupt 0 input. Pin 13: INT1 Interrupt 1 input. Pin 14: T0 Counter 0 clock input. Pin 15: T1 Counter 1 clock input. Pin 16: WR Write to external (additional) RAM. Pin 17: RD Read from external RAM. Pin 18, 19: X2, X1 Internal oscillator input and output. A quartz crystal which specifies operating frequency is usually connected to these pins. Instead of it, miniature ceramics resonators can also be used for frequency stability. Later versions of microcontrollers operate at a frequency of 0 Hz up to over 50 Hz.

Pin 20: GND Ground. Pin 21-28: Port 2 If there is no intention to use external memory then these port pins are configured as general inputs/outputs. In case external memory is used, the higher address byte, i.e. addresses A8-A15 will appear on this port. Even though memory with capacity of 64Kb is not used, which means that not all eight port bits are used for its addressing, the rest of them are not available as inputs/outputs. Pin 29: PSEN If external ROM is used for storing program then a logic zero (0) appears on it every time the microcontroller reads a byte from memory. Pin 30: ALE Prior to reading from external memory, the microcontroller puts the lower address byte (A0-A7) on P0 and activates the ALE output. After receiving signal from the ALE pin, the external register (usually 74HCT373 or 74HCT375 add-on chip) memorizes the state of P0 and uses it as a memory chip address. Immediately after that, the ALU pin is returned its previous logic state and P0 is now used as a Data Bus. As seen, port data multiplexing is performed by means of only one additional (and cheap) integrated circuit. In other words, this port is used for both data and address transmission. Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for data and address transmission with no regard to whether there is internal memory or not. It means that even there is a program written to the microcontroller, it will not be executed. Instead, the program written to external ROM will be executed. By applying logic one to the EA pin, the microcontroller will use both memories, first internal then external (if exists). Pin 32-39: Port 0 Similar to P2, if external memory is not used, these pins can be used as general inputs/outputs. Otherwise, P0 is configured as address output (A0-A7) when the ALE pin is driven high (1) or as data output (Data Bus) when the ALE pin is driven low (0). Pin 40: VCC +5V power supply. 3. Summary In this lecture, the complete architecture of 8051 controller is discussed. Register bank and all special purpose registers are briefly explained. Pin configuration of 8051, Program status word, timer and its functions are also discussed. 4. References 1. The 8051 Microcontroller and Embedded Systems Using Assembly and C Second Edition Muhammad Ali Mazidi, Janice Gillispie Mazidi and Rolin D.McKinlay. 2. Intel 8051 Microcontroller manual 3. http://www.mikroe.com/