Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Dr. S. A. Shinde
Microprocessors
Microprocessors come in all kinds of varieties from the very simple to the very complex Depend on data bus and register and ALU width P could be 4-bit , 8-bit , 16-bit, 32-bit , 64-bit We will discuss two sample of it
8085 as an 8-bit P and 8086/88 as an 16-bit P
All Ps have
Address bus Data bus Control Signals: RD, WR, CLK , RST, INT, . . .
History
Bus width
4 bit
8 bit
16 bit
32 bit
64 bit
Company 8008 8080 8085 Z80 6800 6802 6809 8086/8 80186 80286 Z8000 Z8001 Z8002 68006 68008 68010
intel
4004 4040
80386 80486
80860 pentium
zilog
Motorola
Microprocessor Architecture
The microprocessor can be programmed to perform functions on given data by writing specific instructions into its memory.
The microprocessor reads one instruction at a time, matches it with its instruction set, and performs the data manipulation specified. The result is either stored back into memory or displayed on an output device.
Interrupt
The microprocessors operations are interrupted and the microprocessor executes what is called a service routine. This routine handles the interrupt, (perform the necessary operations). Then the microprocessor returns to its previous operations and continues.
Hold
The 8085 has a pin called HOLD. This pin is used by external devices to gain control of the busses. When the HOLD signal is activated by an external device, the 8085 stops executing instructions and stops using the busses. This would allow external devices to control the information on the busses. Example DMA.
It is important to note that the microprocessor treats memory and I/O devices the same way. Input and output devices simply look like memory locations to the microprocessor. For example, the keyboard may look like memory address A3F2H. To get what key is being pressed, the microprocessor simply reads the data at location A3F2H. The communication process between the microprocessor and peripheral devices consist of the following three steps: Identify the address. Transfer the binary information. Provide the right timing signals.
Address
16
Data
how would we use these address lines to control the multiple chips?
Chip Select
Usually, each memory chip has a CS (Chip Select) input. The chip will only work if an active signal is applied on that input. To allow the use of multiple chips in the make up of memory, we need to use a number of the address lines for the purpose of chip selection.
These address lines are decoded to generate the 2n necessary CS inputs for the memory chips to be used.
Microcomputer Hardware
Address Bus
Depending on the combination on the address lines A15 - A10 , the address range of the specified chip is determined.
Now the chip would have addresses ranging from: 2400 to 27FF. Changing the combination of the address bits connected to the chip select changes the address range for the memory chip.
FFFF
FFFF
Low-Order
Used for location selection within a memory chip.
All of the above discussion has been regarding memory length. Lets look at memory width. We said that the width is the number of bits in each memory word.
We have been assuming so far that our memory chips have the right width. What if they dont? It is very common to find memory chips that have only 4 bits per location. How would you design a byte wide memory system using these chips? We use two chips for the same address range. One chip will supply 4 of the data bits per address and the other chip supply the other 4 data bits for the same address.
Data Lines
8085 Interrupts
Interrupt is a process where an external device can get the attention of the microprocessor.
The process starts from the I/O device The process is asynchronous.
Interrupts
Classification of Interrupts
Interrupts can be classified into two types:
Maskable Interrupts (Can be delayed or Rejected) Non-Maskable Interrupts (Can not be delayed or Rejected)
Interrupts
An interrupt is considered to be an emergency signal that may be serviced.
The Microprocessor may respond to it as soon as possible.
Responding to Interrupts
Responding to an interrupt may be immediate or delayed depending on whether the interrupt is maskable or non-maskable and whether interrupts are being masked or not. There are two ways of redirecting the execution to the ISR depending on whether the interrupt is vectored or non-vectored. Vectored: The address of the subroutine is already known to the Microprocessor Non Vectored: The device will have to supply the address of the subroutine to the Microprocessor
RST 5.5, RST 6.5, RST 7.5 are all automatically vectored.
RST 5.5, RST 6.5, and RST 7.5 are all maskable.
8085 Interrupts
TRAP RST7.5 RST6.5 RST 5.5 INTR INTA
8085
Example: Let , a device interrupts the Microprocessor using the RST 7.5 interrupt line.
Because the RST 7.5 interrupt is vectored, Microprocessor knows , in which memory location it has to go using a call instruction to get the ISR address. RST7.5 is knows as Call 003Ch to Microprocessor. Microprocessor goes to 003C location and will get a JMP instruction to the actual ISR address. The Microprocessor will then, jump to the ISR location The process is illustrated in the next slide..
Restart Sequence
The restart sequence is made up of three machine cycles
In the 1st machine cycle:
The microprocessor sends the INTA signal. While INTA is active the microprocessor reads the data lines expecting to receive, from the interrupting device, the opcode for the specific RST instruction.
The 3 outputs carry the index of the highest priority active input. Figure 12.4 in the book shows how this circuit can be used with a Tri-state buffer to implement an interrupt priority scheme.
The vectors for these interrupt fall in between the vectors for the RST instructions. Thats why they have names like RST 5.5 (RST 5 and a half).
Through individual mask flip flops that control the availability of the individual interrupts.
These flip flops control the interrupts individually.
RST 6.5
M 6.5
RST 5.5
M 5.5
INTR
Interrupt Enable Flip Flop
Bit 4 of the accumulator in the SIM instruction allows explicitly resetting the RST 7.5 memory even if the microprocessor did not respond to it. Bit 5 is not used by the SIM instruction
Triggering Levels
RST 7.5 is positive edge sensitive.
When a positive edge appears on the RST7.5 line, a logic 1 is stored in the flip-flop as a pending interrupt. Since the value has been stored in the flip flop, the line does not have to be high when the microprocessor checks for the interrupt to be recognized. The line must go to zero and back to one before a new interrupt is recognized.
SDI P7.5 P6.5 P5.5 IE M7.5 M6.5 M5.5 RST5.5 Mask RST6.5 Mask RST7.5 Mask
Serial Data In RST5.5 Interrupt Pending RST6.5 Interrupt Pending RST7.5 Interrupt Pending
0 - Available 1 - Masked
TRAP
TRAP is the only non-maskable interrupt.
It does not need to be enabled because it cannot be disabled.
It has the highest priority amongst interrupts. It is edge and level sensitive.
It needs to be high and stay high to be recognized. Once it is recognized, it wont be recognized again until it goes low, then high again.
TRAP
No
Yes
No
8255 PPI
A7 A6 A5 A4 A3 A2 A1 A0 1 1 0 0 0 X X 0
Port A = C0h Port B = C2h Port C = C4h CR = C6h PCs use 60h-63h
- Speaker, timer, KB
8255 Control
Two groups
Group A = A0-A7 + C4-C7 Group B = B0-B7 + C0-C3
8255 Control
If A0=A1=1, Data becomes control byte (write only to CR) MSB=1 : Mode control D0-D2: Group B control D3-D6: Group A control (2 mode select bits) MSB=0: Allows you to set or reset any port C bit.
7 0 6 X 5 X 4 X 3 BS 2 BS 1 BS 0 S/R
sets/resets
8255 Control
MODE 0:
- Simple I/O operation - Port pins are assigned to be level-sensitive inputs or latched outputs. CR = 1 0 0 x x 0 x x Where the x would define the directionality of each port via the last slide.
Example
What is the mode and I/O configuration for ports A, B, and C of an 8255 after its control register is loaded with
90h? 81h? 82h?
Ports A & B are in mode 0 - simple latched outputs. (CR = 80h) Port A = 7 segment data inputs Port B selects which segment of the bank will display. I/O ports 0700h-0703h (via the PAL) WR pin is strobed by the PAL output as well (not shown)
15 1
14 1
13 1
12 1
11 1
10 1
9 1
8 1
7 0
6 0
5 0
4 0
3 0
2 0
1 x
0 x
Other examples
Please analyze the other Mode 0 examples in the book:
- LCD interface - Stepper motor interface - Key matrix interface
8279 Functionality
Keyboard Interface
KB matrix range: 2x2 (4 keys) - 8x8 (64 keys) A pressed key connects one row with one column RL0-7 and SL0-2 are continuously and sequentially queried internally - looking for a closed switch Pull-up resistors are internal to the 8279
010Z0AAA - Read FIFO control: selects address of keystroke (000-111) from internal FIFP buffer; Z selects auto-increment. 011ZAAAA - Display read control: selects read address from one of the display RAM positions; Z selects auto-increment used is info in display RAM must be read. 100ZAAAA - Display write control: AAAA addresses the position in RAM to be written 1010WWBB - Display write inhibit: inhibits writing to either half of the display RAM location. 1100CCFA - Clear control. 111E000 - Clear IRQ pin.
8086MP
U? 33 22 19 21 18 MN READY CLK RESET INTR 16 AD0 15 AD1 14 AD2 13 AD3 12 AD4 11 AD5 10 AD6 9 AD7 8 AD8 7 AD9 6 AD10 5 AD11 4 AD12 3 AD13 2 AD14 39 AD15 38 A16/S3 37 A17/S4 36 A18/S5 35 A19/S6 34 BHE/S7 26 DEN 27 DT/R 28 M/IO HLDA HOLD NMI TEST 8086MIN 32 RD 29 WR 25 ALE 24 INTA
30 31 17 23
PROGRAMING MODEL As a programmer of the 8086 or 8088 you must become familiar with the various registers in the EU and BIU.
Gnd (pin 1 and 20) : Ground AD0..AD7 , AD8..AD15 , A19/S6, A18/S5, A17/S4, A16/S3 : 20 -bit Address Bus MN/MX (input) : Indicates Operating mode READY (input , Active High) : take P to wait state CLK (input) : Provides basic timing for the processor RESET (input, Active High) : At least 4 clock cycles Causes the P immediately terminate its present activity. TEST (input , Active Low) : Connect this to HIGH HOLD (input , Active High) : Connect this to LOW (BR) HLDA (output , Active High) : Hold Ack (BG) INTR (input , Active High) : Interrupt request INTA (output , Active Low) : Interrupt Acknowledge NMI (input , Active High) : Non-maskable interrupt
Register Set
A : Accumulator Register F : Flag register Two sets of six general-purpose registers
may be used as 8-bit A F B C D E H L (A F B C D E H L)
The Alternative registers (A F B C D E H L) not visible to the programmer but can access via:
EXX EX AF, AF (BC)<->(BC') , (DE)<->(DE') , (HL)<->(HL') (AF)<->(AF')
Register Set(cont)
4 (16-bit) registers hold memory address (pointers)
index registers (IX) and (IY) are 16-bit memory pointers 16 bit stack pointer (SP) Program counter (PC)
Flag Register
S Sign Flag (1:negativ)* Z Zero Flag (1:Zero) P Parity Flag (1: Even) V Overflow Flag (1:Overflow)* N Operation Flag (1:previous Operation was subtraction)** C Carry Flag (1: Carry from Bit n-1 to Bit n, with n length of operand) *: 2-complement number representation **: used in DAA-operation for BCD-arithmetic
7 6 5 4 3 2 1 0
S Z X H X
P V
N C
The R register
Is increased at every first machine cycle (M1). Bit 7 of it is never changed by this; only the lower 7 bits are included in the addition. So bit 7 stays the same Bit 7 can be changed using the LD R,A instruction. LD A,R a nd LD R,A access the R register after it is increased R is often used in programs for a random value, which is good but of course not truly random.
IO read/write cycle
Interrupts
There are two types of interrupts: non mask-able (NMI)
Could not be masked Jump to 0066H of memory
mask-able(INT)
Has 3 mode Can be set with the IM x Instruction IM 0 sets Interrupt mode 0 IM 1 sets Interrupt mode 1 IM 2 sets Interrupt mode 2
Mode 0:
Interrupt Modes
An 8 bit opcode is Fetched from Data BUS and executed The source interrupt device must put 8 bit opcode at data bus 8 bit opcode usually is RST p instructions
Mode 1:
A jump is made to address 0038h No value is required at data bus
Mode 2:
A jump is made to address (register I 256 + value from interrupting device that puts at bus) I is high 8 bit of interrupt vector Value is low 8 bit of interrupt vector
Addressing Modes
Immediate Immediate Extended Modified Page Zero Addressing (rst p) Relative Addressing
Jump Relative (2 byte)
One Byte Op Code 8-Bit Twos Complement Displacement (A+2)
Extended Addressing
Absolute jump
One byte opcode 2 byte address
Indexed Addressing
(Index Register + Displacement) (IX+d) 2 byte opcode 1 byte displacement
Addressing Modes(cont.)
Register Addressing
LD C,B
Implied Addressing
Op Code implies other operand(s) ADD E
Bit Addressing
set, reset, and test instructions. SET 3,A RES 7,B
Introduction to MICROCONTROLLERS
Dr. Y .Narasimha Murthy Ph.D Sri Saibaba National College (Autonomous) ANANTAPUR-515001(A.P)
Overview
Introduction Block Diagram and Pin Description of the 8051 Registers Memory mapping in 8051 Stack in the 8051 I/O Port Programming Timer Interrupt
Microprocessors
General-purpose microprocessor
CPU for Computers No RAM, ROM, I/O on CPU chip itself Example Intels Data Bus x86, Motorolas CPU 680x0
GeneralPurpose Microprocessor RAM ROM I/O Port Timer Serial COM Port
Address Bus
Microcontrollers
A smaller computer On-chip RAM, ROM, I/O ports... Example Motorolas 6811, Intels 8051, Zilogs Z8 and PIC 16X
CPU RAM ROM Serial Timer COM Port
I/O Port
Microcontroller
CPU, RAM, ROM, I/O and timer are all on a single chip Fixed amount of on-chip ROM, RAM, I/O ports for applications in which cost, power and space are critical Dedicated -purpose
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
8031
NO
8051
4kB
8052
8kB 256 3 32 1
8
4kB UV 128 2 32 1
6
In 1983 INTEL Introduced 16-bit microcontroller namely 8096 Later INTEL introduced 80c196 series of 16-bit microcontrollers for mainly industrial applications 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
Block Diagram of Microcontroller-8051 MicrocontrollerExternal interrupts Interrupt Control On-chip ROM for program code
Timer/Counter
On-chip RAM
Timer 1 Timer 0
Counter Inputs
CPU
OSC
Bus Control
4 I/O Ports
Serial Port
P0 P1 P2 P3
TxD RxD
Address/Data
Block Diagram-8051
8051
Registers
A B R0 R1 R2 R3 R4 R5 R6 R7 Some 8-bitt Registers of the 8051 Some 8051 16-bit Register PC PC DPTR DPH DPL
8k
0000H
32k
30H 2FH
Bit-Addressable RAM
20H
1FH 18H 17H 10H 0FH 08H 07H 00H Register Bank 3 Register Bank 2 (Stack) Register Bank 1 Register Bank 0
TMOD Register:
Gate : When set, timer only runs while INT(0,1) is C/T : Counter/Timer select bit. M1 : Mode bit 1. M0 : Mode bit 0.
high.
TCON Register:
TF1: Timer 1 overflow flag. TR1: Timer 1 run control bit. TF0: Timer 0 overflag. TR0: Timer 0 run control bit. IE1: External interrupt 1 edge flag. IT1: External interrupt 1 type flag. IE0: External interrupt 0 edge flag. IT0: External interrupt 0 type flag.
Interrupts
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. .
4) Mazidi and Mazidi, The 8051 microcontroller and embedded sytems Pearson education. 5) Peatman,J.B. Design with microcontrollers and microcomputers, McGraw Hill 6) Sewart. J.W. The 8051 Microcontroller Hardware, Software and Interfacing Prentice Hall 7) Ayala Kenneth, The 8051 Microntroller Architecture, Programming and Applications Delmar Publ. 8) Ajay Deshmukh, Microcontrollers TATA McGraw Hill
Rajkamal, Microcontrollers - Architecture, Programming Pearson Publ. 10) Myke Predko, Programming the 8051 Microcontroller McGraw Hill 11) Michael J. Pont, Embedded C - Addison Wesely Publ. 12) Steve Heath, Embedded system design Heinemann Publ. 13) Frank Vahid, Embedded systems a unified hardware/software Introduction John Wiley and sons Publ. 14) Barnett Cox & Ocull, Embedded C Programming & the Microchip PIC, Thomson Delmar Learning.
9)
Website References
1. 2. 3. 4. 5. 6.
7. 8.
http://www.eg3 http://www.eg3.com http://www.ARM.MCU.com http://www.mcjournal.com http://www.iar.com http://www.keil.com http://www.semiconductors.philips.com/ microcontrollers 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!