Docsity

(r18a0415) microprocessors and microcontrollers, Lecture notes of Microprocessors

Toggle sidebar
bg1
MALLA REDDY COLLEGE OF ENGINEERING & TECHNOLOGY
(Autonomous Institution – UGC, Govt. of India)
Recognized under 2(f) and 12 (B) of UGC ACT 1956
(Affiliated to JNTUH, Hyderabad, Approved by AICTE - Accredited by NBA & NAAC – ā€˜A’ Grade - ISO
9001:2015 Certified)
Maisammaguda, Dhulapally (Post Via. Kompally), Secunderabad – 500100,
Telangana State, India
DEPARTMENT OF
ELECTRONICS & COMMUNICATION ENGINEERING
(R18A0415)
MICROPROCESSORS AND MICROCONTROLLERS
For
III Year B.Tech EEE-II SEM
Prepared by
M.RAMANJANEYULU, Associate Professor
Mr. KDK AJAY, Assistant Professor
Dr.S.SASIKANTH, Professor
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download (r18a0415) microprocessors and microcontrollers and more Lecture notes Microprocessors in PDF only on Docsity!

MALLA REDDY COLLEGE OF ENGINEERING & TECHNOLOGY

(Autonomous Institution – UGC, Govt. of India) Recognized under 2(f) and 12 (B) of UGC ACT 1956 (Affiliated to JNTUH, Hyderabad, Approved by AICTE - Accredited by NBA & NAAC – ā€˜A’ Grade - ISO 9001:2015 Certified) Maisammaguda, Dhulapally (Post Via. Kompally), Secunderabad – 500100, Telangana State, India

DEPARTMENT OF

ELECTRONICS & COMMUNICATION ENGINEERING

(R18A0415)

MICROPROCESSORS AND MICROCONTROLLERS

For

III Year B.Tech EEE-II SEM Prepared by M.RAMANJANEYULU, Associate Professor Mr. KDK AJAY, Assistant Professor Dr.S.SASIKANTH, Professor

MALLA REDDY COLLEGE OF ENGINEERING AND TECHNOLOGY III Year B.Tech EEE-II SEM L T/P/D C 3 - / - /- 3 (R18A0415) MICROPROCESSORS AND MICROCONTROLLERS COURSE OBJECTIVES:

  • To understand the basics of microprocessors and microcontrollers architectures and its functionalities.
  • To develop an in-depth understanding of the operation of microprocessors and microcontrollers, machine language programming & interfacing techniques.
  • To design and develop Microprocessor/ microcontroller based systems for real time applications using low level language like ALP.
  • To understand the concepts of ARM processor. UNIT - I 8086 ARCHITECTURE: Architecture of 8086, Register Organization, Programming Model, Memory addresses, Memory Segmentation, Physical Memory Organization, Signal descriptions of 8086 - Common Function Signals, Minimum and Maximum mode signals, Timing diagrams. UNIT - II INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING OF 8086: Instruction formats, Addressing modes, Instruction Set, Assembler Directives, Procedures, Macros, Simple Programs involving Logical, Branch and Call Instructions, Sorting, Evaluating Arithmetic Expressions, String Manipulations. UNIT - III I/O INTERFACE: 8255 PPI, Various Modes of Operation and Interfacing to 8086, D/A and A/D Converter, Stepper motor, Interfacing of DMA controller 8257 INTERFACING WITH ADVANCED DEVICES: Memory Interfacing to 8086, Interrupt Structure of 8086, Vector Interrupt Table, Interrupt Service Routine, architecture of 8259. COMMUNICATION INTERFACE: Serial Communication Standards, Serial Data Transfer Schemes, 8251 USART Architecture and Interfacing. UNIT - IV INTRODUCTION TO MICROCONTROLLERS: Overview of 8051 Microcontroller, Architecture, I/O Ports, Memory Organization, Addressing Modes and Instruction set of 8051, Simple Programs, memory interfacing to 8051 UNIT - V 8051 REAL TIME CONTROL: Programming Timer Interrupts, Programming External Hardware Interrupts, Programming the Serial Communication Interrupts, Programming 8051 Timers and Counters. ARM PROCESSOR: Fundamentals, Registers, Current program status register, Pipeline, Interrupt and the vector table.

UNIT - I

8086 Architecture

 Architecture of 8086  Register Organization  Programming Model  Memory addresses  Memory Segmentation  Physical Memory Organization  Signal descriptions of 8086- Common Function Signals  Minimum and Maximum mode signals  Timing diagrams

UNIT-I

8086 Architecture

Introduction to Microprocessors

A microprocessor is a computer processor which incorporates the functions of a computer's central processing unit (CPU) on a single integrated circuit (IC), or at most a few integrated circuits The microprocessor is a multipurpose, clock driven, register based, digital-integrated circuit which accepts binary data as input, processes it according to instructions stored in its memory, and provides results as output. Microprocessors contain both combinational logic and sequential digital logic. Microprocessors operate on numbers and symbols represented in the binary numeral system. Generation of Microprocessors:  INTEL 4004 ( 1971) ļ‚— 4 - bit microprocessor ļ‚— 4 KB main memory ļ‚— 45 instructions ļ‚— PMOS technology ļ‚— was first programmable device which was used in calculators  INTEL 8008 (1972) ļ‚— 8 - bit version of 4004 ļ‚— 16 KB main memory ļ‚— 48 instructions ļ‚— PMOS technology ļ‚— Slow  Intel 8080 (1973) ļ‚· 8 - bit microprocessor ļ‚— 64 KB main memory ļ‚— 2 microseconds clock cycle time ļ‚— 500,000 instructions/sec ļ‚— 10X faster than 8008 ļ‚— NMOS technology ļ‚— Drawback was that it needed three power supplies.

General Architecture of Microprocessors

Buses

Register Organization of 8086 8086 has a powerful set of registers containing general purpose and special purpose registers. All the registers of 8086 are 16-bit registers. The general purpose registers, can be used either 8-bit registers or 16-bit registers. The general purpose registers are either used for holding the data, variables and intermediate results temporarily or for other purpose like counter or for storing offset address for some particular addressing modes etc. The special purpose registers are used as segment registers, pointers, index registers or as offset storage registers for particular addressing modes. Fig 1.4 shows register organization of 8086. We will categorize the register set into four groups as follows: General data Registers: The registers AX, BX, CX, and DX are the general 16-bit registers. AX Register: Accumulator register consists of two 8-bit registers AL and AH, which can be combined together and used as a 16- bit register AX. AL in this case contains the low-order byte of the word, and AH contains the high- order byte. Accumulator can be used for I/O operations, rotate and string manipulation. BX Register: This register is mainly used as a base register. It holds the starting base location of a memory region within a data segment. It is used as offset storage for forming physical address in case of certain addressing mode. CX Register: It is used as default counter or count register in case of string and loop instructions.

Pointers and index registers.

The pointers contain within the particular segments. The pointers IP, BP, SP usually contain offsets within the code, data and stack segments respectively Stack Pointer (SP) is a 16-bit register pointing to program stack in stack segment. Base Pointer (BP) is a 16-bit register pointing to data in stack segment. BP register is usually used for based, based indexed or register indirect addressing. Source Index (SI) is a 16-bit register. SI is used for indexed, based indexed and register indirect addressing, as well as a source data addresses in string manipulation instructions. Destination Index (DI) is a 16-bit register. DI is used for indexed, based indexed and register indirect addressing, as well as a destination data address in string manipulation instructions.

Flag Register:

Flags Register determines the current state of the processor. They are modified automatically by CPU after mathematical operations, this allows to determine the type of the result, and to determine conditions to transfer control to other parts of the program. The 8086 flag register as shown in the fig 1.6. 8086 has 9 active flags and they are divided into two categories:

  1. Conditional Flags
  2. Control Flags Conditional flags are as follows: Carry Flag (CY): This flag indicates an overflow condition for unsigned integer arithmetic. It is also used in multiple-precision arithmetic. Auxiliary Flag (AC): If an operation performed in ALU generates a carry/barrow from lower nibble (i.e. D0 – D3) to upper nibble (i.e. D4 – D7), the AC flag is set i.e. carry given by D3 bit to D4 is AC flag. This is not a general-purpose flag, it is used internally by the Processor to perform Binary to BCD conversion. Parity Flag (PF): This flag is used to indicate the parity of result. If lower order 8-bits of the result contains even number of 1’s, the Parity Flag is set and for odd number of 1’s, the Parity flag is reset. Zero Flag (ZF): It is set; if the result of arithmetic or logical operation is zero else it is reset.

8086 Architecture

The 8086 is mainly divided into mainly two blocks

  1. Execution Unit (EU) 2.Bus interface Unit (BIU) Dividing the work between these two will speedup the processing 1) EXECUTION UNIT( EU) The Execution unit tells the BIU where to fetch instructions or data from  decodes instructions and  Executes instructions The Execution unit contains:
    1. Control circuitry
    2. ALU
    3. FLAGS
    4. General purpose Registers
    5. Pointer and Index Registers Control Circuitry:  It directs internal operations.

 A decoder in the EU translates instructions fetched from memory Into series of actions which the EU carries out Arithmetic Logic Unit: 16 bit ALU Used to carry the operations  ADD  SUBTRACT  XOR  INCREMENT  DECREMENT  COMPLEMENT  SHIFT BINARY NUMBERS FLAG REGISTERS:  A flag is a flip flop that indicates some condition produced by execution of an instruction or controls certain operation of the EU.  It is 16 bit  It has nine active flags Divided into two types

  1. Conditional flags
  2. Control flags Conditional Flags Carry Flag (CY): This flag indicates an overflow condition for unsigned integer arithmetic. It is also used in multiple-precision arithmetic. Auxiliary Flag (AC): If an operation performed in ALU generates a carry/barrow from lower nibble (i.e. D0 – D3) to upper nibble (i.e. D4 – D7), the AC flag is set i.e. carry given by D3 bit to D4 is AC flag. This is not a general-purpose flag, it is used internally by the Processor to perform Binary to BCD conversion. Parity Flag (PF): This flag is used to indicate the parity of result. If lower order 8-bits of the result contains even number of 1’s, the Parity Flag is set and for odd number of 1’s, the Parity flag is reset.

CX Register: It is used as default counter or count register in case of string and loop instructions. DX Register: Data register can be used as a port number in I/O operations and implicit operand or destination in case of few instructions. In integer 32 - bit multiply and divide instruction the DX register contains high-order word of the initial or resulting number. 2) BUS INTERFACE UNIT (BIU) The BIU sends out  Addresses  Fetches instructions from memory  Read data from ports and memory Or The BIU handles all transfer of data and addresses on the buses for the Execution Unit The Bus interface unit contains

  1. Instruction Queue
  2. Instruction pointer
  3. Segment registers
  4. Address Generator Instruction Queue: BIU gets upto 6 bytes of next instructions and stores them in the instruction queue. When EU executes instructions and is ready for its next instruction, then it simply reads the instruction from this instruction queue resulting in increased execution speed. Fetching the next instruction while the current instruction executes is called pipelining. ( based on FIFO) .This is much faster than sending out an addresses to the system memory and waiting for memory to send back the next instruction byte or bytes .Here the Queue will be dumped and then reloaded from the new Address. Segment Register: The 8086 20 bit addresses So it can address upto 2^20 in memory ( 1 Mbyte) but at any instant it can address upto 4 64 KB segments. This four segments holds the upper 16 bits of the starting address of four memory segments that the 8086 is working with it at particular time .The BIU always inserts zeros for the lowest 4 bits of the 20 bit starting address Example : If the code segment register contains 348AH then the code segment starts at 348A0H .In other words a 64Kbyte segment can be located anywhere within 1MByte address Space but the segment will always starts at an address with zeros in the lowest 4 bits

Stack: is a section of memory set aside to store addresses and data while subprogram executes is often called segment base. The stack segment register always holds the upper 16 bit starting address of program stack. The extra segment register and data segment register is used to hold the upper 16 bit starting addresses of two memory segments that are used for data. Instruction Pointer holds the 16 bit address or offset of the next code byte within the code segment. The value contained in the Instruction Pointer called as Offset because the value must be added to the segment base address in CS to produce the required 20 bit address. CS register contains the Upper 16 bit of the starting address of the code segment in the 1 Mbyte address range the instruction pointer contains a 16 bit offset which tells wherein that 64 Kbyte code segment the next instruction byte has to be fetched from. Stack Register and Stack Pointer: Stack: is a section of memory set aside to store addresses and data while subprogram executes is often called segment base. The stack segment register always holds the upper 16 bit starting address of program stack. The Stack pointer (SP) holds the 16 bit offset from the starting of the segment to the memory location where a word was most recently stored .The memory location where the word is stored is called as top of the stack

The point to note is that the beginning segment address must begin at an address divisible by 16.Also note that the four segments need not be defined separately. It is allowable for all four segments to completely overlap (CS = DS = ES = SS). Logical and Physical Address Addresses within a segment can range from address 00000h to address 0FFFFh. This corresponds to the 64K-bytelength of the segment. An address within a segment is called an offset or logical address. A logical address gives the displacement from the base address of the segment to the desired location within it, as opposed to its "real" address, which maps directly anywhere into the 1 MByte memory space. This "real" address is called the physical address. What is the difference between the physical and the logical address? The physical address is 20 bits long and corresponds to the actual binary code output by the BIU on the address bus lines. The logical address is an offset from location 0 of a given segment.

You should also be careful when writing addresses on paper to do so clearly. To specify the logical address XXXX in the stack segment, use the convention SS:XXXX, which is equal to [SS] * 16 + XXXX. Logical address is in the form of: Base Address: Offset Offset is the displacement of the memory location from the starting location of the segment. To calculate the physical address of the memory, BIU uses the following formula:

Physical Address = Base Address of Segment * 16 + Offset