Professional Documents
Culture Documents
MEM ORY
INPUT-OUTPUT
EE6502 Microprocessor & CONTRO L
Microcontroller
DATAPATH
CPU
1 2
5 6
www.studentsfocus.com 1
The 8085 Bus Structure The 8085 Bus Structure
The 8-bit 8085 CPU (or MPU – Micro Processing Unit) Address Bus
communicates with the other units using a 16-bit address
bus, an 8-bit data bus and a control bus. ! Consists of 16 address lines: A0 – A15
7 8
! Consists of various lines carrying the control ! Store temporary data in RAM during execution
signals such as read / write enable, flag bits.
9 10
11 12
www.studentsfocus.com 2
The 8085: CPU Internal Structure The 8085: CPU Internal Structure
Registers Flag Bits
! Six general purpose 8-bit registers: B, C, D, E, H, L ! Indicate the result of condition tests.
! They can also be combined as register pairs to ! Carry, Zero, Sign, Parity, etc.
perform 16-bit operations: BC, DE, HL
! Conditional operations (IF / THEN) are executed
! Registers are programmable (data load, move, etc.) based on the condition of these flag bits.
Accumulator Program Counter (PC)
! Single 8-bit register that is part of the ALU ! ! Contains the memory address (16 bits) of the
instruction that will be executed in the next step.
! Used for arithmetic / logic operations – the result is
always stored in the accumulator. Stack Pointer (SP)
13 14
15 16
17 18
www.studentsfocus.com 3
8085 Functional Block Diagram
19
www.studentsfocus.com 4
UNIT-II
www.studentsfocus.com
02.ADDITION OF TWO 8 BIT NUMBERS
(C) BY INDIRECT ADDRESSING MODE
www.studentsfocus.com
02.SUBTRACTION OF TWO 8 BIT NUMBERS
(e) BY IMMEDIATE ADDRESSING MODE
MEMORY LABEL MNEMONICS OPCODE COMMENTS
A000 START MVI A,09 3E MOVE A!09
A001 09
A002 SUI 08 D6 SUB IMMEDIATELY BY 08 A!A-08
A003 08
A004 STA B000 32 STORE A TO B000
A005 00
A006 B0
A007 STOP HLT 76 HALT
www.studentsfocus.com
02.SUBTRACTION OF TWO 8 BIT NUMBERS
(g) BY INDIRECT ADDRESSING MODE
MEMORY LABEL MNEMONICS OPCODE COMMENTS
A000 START LXI H,B000 21 LOAD DATA IN HL PAIR
A001 00
A002 B0
A003 MOV A,M 7E MOVE A!M
A004 INX H 23 INCREMENT H
A005 SUB M 96 SUB A!A-M
A006 INX H 23 INCREMENT H
A007 MOV M,A 77 MOVE M!A
A008 STOP HLT 76 HALT
www.studentsfocus.com
03(b).DIVISION OF TWO 8 BIT NUMBERS
www.studentsfocus.com
04(b)SUBTRACTION OF TWO 16 BIT NUMBERS
www.studentsfocus.com
05(b) DIVISION OF A 16 BIT NUMBER BY 16 BIT NUMBER
www.studentsfocus.com
06.CODE CONVERSION
(a)BCD TO BINARY
www.studentsfocus.com
06.CODE CONVERSION
(b) BINARY TO BCD
www.studentsfocus.com
06.CODE CONVERSION
(C)HEX TO ASCII
MEMORY LABEL MNEMONICS OPCODE COMMENTS
8000 START LDA 8050 3A,50,80 LOAD ACC WITH DATA
8003 CPI 0A FE,0A COMPUTE IMMEDIATELY 0A
8005 JC L1 DA,0A,80 JUMP IF CARRY TO L1
8008 ADI 07 C6,07 ADD IMMEDIATE 07
800A L1 ADI 30 C6,30 ADD IMMEDIATELY 30
800C STA 8051 32,51,80 STORE THE RESULT
800F STOP HLT 76 HALT
06.CODE CONVERSION
(d)ASCII TO HEX
www.studentsfocus.com
07.SORTING OF NUMBERS
(a)ASCENDING ORDER
MEMORY LABEL MNEMONICS OPCODE COMMENTS
8000 START MVI C,05 0E,05 C!05
8002 L4 LXI H,8050 21,50,80 LOAD ADDRESS IN HL
8005 MVI D,05 16,05 D!05
8007 MOV A,M 7E A!H
8008 L3 INX H 23 INCREMENT HL
8009 MOV B,M 46 B!H
800A CMP B B8 COMPARE B WITH A
800B JNC L1 D2,14,80 JUMP ON NO CARRY
800E DCX H 2B DECREMENT HL
800F MOV M,A 77 M!A
8010 MOV A,B 78 A!B
8011 JMP L2 C3,16,80 UNCONDITIONAL JUMP
8014 L1 DCX H 2B DECREMENT HL
8015 MOV M,B 70 H!B
8016 L2 INX H 23 INCREMENT HL
8017 DCR D 15 DECREMENT D
8018 JNZ L3 C2,08,80 JUMP ON NO ZERO
801B MOV M,A 77 M!A
801C DCR C 0D DECREMENT C
801D JNZ L4 C2,02,80 JUMP ON NO ZERO
8020 STOP HLT 76 HALT
www.studentsfocus.com
07.SORTING OF NUMBERS
(b)DESCENDING ORDER
MEMORY LABEL MNEMONICS OPCODE COMMENTS
8000 START MVI C,05 0E,05 C!05
8002 L4 LXI H,8050 21,50,80 LOAD ADDRESS IN HL
8005 MVI D,05 16,05 D!05
8007 MOV A,M 7E A!H
8008 L3 INX H 23 INCREMENT HL
8009 MOV B,M 46 B!H
800A CMP B B8 COMPARE B WITH A
800B JC L1 D2,14,80 JUMP ON NO CARRY
800E DCX H 2B DECREMENT HL
800F MOV M,A 77 M!A
8010 MOV A,B 78 A!B
8011 JMP L2 C3,16,80 UNCONDITIONAL JUMP
8014 L1 DCX H 2B DECREMENT HL
8015 MOV M,B 70 H!B
8016 L2 INX H 23 INCREMENT HL
8017 DCR D 15 DECREMENT D
8018 JNZ L3 C2,08,80 JUMP ON NO ZERO
801B MOV M,A 77 M!A
801C DCR C 0D DECREMENT C
801D JNZ L4 C2,02,80 JUMP ON NO ZERO
8020 STOP HLT 76 HALT
www.studentsfocus.com
08.MESSAGE DISPLAY
SINGLE CHARACTER
08.MESSAGE DISPLAY
MULTIPLE CHARACTER
MEMORY LABEL MNEMONICS OPCODE COMMENTS
8000 MVI A,90 3E,90 CONTROL
WORD
8002 OUT 31 DB,31
8004 MVI A,67 3E,67 DATA 1
8006 OUT 30 D3,30
8008 MVI A,93 3E,93 DATA 2
800A OUT 30 D3,30
800C MVI A,97 3E,97 DATA 3
800E OUT 30 D3,30
8010 MVI A,97 3E,97 DATA 4
8012 OUT 30 D3,30
8014 MVI A,60 3E,60 DATA 5
8016 OUT 30 D3,30
8018 MVI A,97 3E,97 DATA 6
801A 0UT30 D3,30
801C HLT 76 HALT
www.studentsfocus.com
MICRO CONTROLLER 8051
III UNIT
Contents
• Introduction
• Block Diagram and Pin Description of the 8051
• Instruction format and addressing modes
• Interrupt structure
• Timer
• I/O ports
• Serial communication
www.studentsfocus.com 1
The necessary tools for a
microprocessor/controller
Microprocessors:
General-purpose microprocessor
• CPU for Computers
• No RAM, ROM, I/O on CPU chip itself
• Example Intel’s x86, Motorola’s 680x0
www.studentsfocus.com 2
Microcontroller :
• A smaller computer
• On-chip RAM, ROM, I/O ports...
• Example Motorola’s 6811, Intel’s 8051, Zilog’s Z8 and PIC 16X
www.studentsfocus.com 3
Embedded System
www.studentsfocus.com 4
Block Diagram
External interrupts
On-chip Timer/Counter
CPU
Bus Serial
4 I/O Ports
OSC Control Port
P0 P1 P2 P3 TxD RxD
Address/Data
www.studentsfocus.com 5
Pin Description of the 8051
P1.0 1 40 Vcc
P1.1 2 39 P0.0(AD0)
P1.2 3 38 P0.1(AD1)
P1.3
P1.4
4
5
8051 37
36
P0.2(AD2)
P0.3(AD3)
P1.5 6 (8031) 35 P0.4(AD4)
P1.6 7 34 P0.5(AD5)
P1.7 8 33 P0.6(AD6)
RST 9 32 P0.7(AD7)
(RXD)P3.0 10 31 EA/VPP
(TXD)P3.1 11 30 ALE/PROG
(INT0)P3.2 12 29 PSEN
(INT1)P3.3 13 28 P2.7(A15)
(T0)P3.4 14 27 P2.6(A14)
(T1)P3.5 15 26 P2.5(A13)
(WR)P3.6 16 25 P2.4(A12)
(RD)P3.7 17 24 P2.3(A11)
XTAL2 18 23 P2.2(A10)
XTAL1 19 22 P2.1(A9)
GND 20 21 P2.0(A8)
www.studentsfocus.com 6
Pins of 8051 1/4
• Vcc pin 40
– Vcc provides supply voltage to the chip.
– The voltage source is +5V.
• GND pin 20 ground
• XTAL1 and XTAL2 pins 19,18
C2
XTAL2
30pF
C1
XTAL1
30pF
GND
www.studentsfocus.com 7
Example :
Solution:
www.studentsfocus.com 8
Figure (b). Power-On RESET Circuit
Vcc
10 uF 31
EA/VPP
30 pF X1
19
11.0592 MHz
8.2 K
X2
18
30 pF
RST
9
www.studentsfocus.com 9
Pins of 8051 4/4
www.studentsfocus.com 10
Hardware Structure of I/O Pin
• Each pin of I/O ports
– Internal CPU bus communicate with CPU
– A D latch store the value of this pin
• D latch is controlled by “Write to latch”
– Write to latch 1 write data into the D latch
– 2 Tri-state buffer #
• TB1: controlled by “Read pin”
– Read pin 1 really read the data present at the pin
• TB2: controlled by “Read latch”
– Read latch 1 read value from internal latch
– A transistor M1 gate
• Gate=0: open
• Gate=1: close
D Latch:
www.studentsfocus.com 11
A Pin of Port 1
TB1
Read pin P0.x
8051 IC
TB1
Read pin
8051 IC
www.studentsfocus.com 12
Writing “0” to Output Pin P1.X
TB1
Read pin
8051 IC
1 1 P1.X pin
Internal CPU bus D Q
P1.X
0 M1
Write to latch Clk Q
TB1
Read pin
3. Read pin=1 Read latch=0
Write to latch=1
8051 IC
www.studentsfocus.com 13
Reading “Low” at Input Pin
TB1
Read pin
3. Read pin=1 Read latch=0
Write to latch=1
8051 IC
Other Pins
www.studentsfocus.com 14
A Pin of Port 0
Read latch
TB2
TB1
Read pin P1.x
8051 IC
Vcc
10 K
P0.0
DS5000 P0.1
Port
P0.2
8751 P0.3
8951 P0.4 0
P0.5
P0.6
P0.7
www.studentsfocus.com 15
MICROPROCESSOR AND
MICROCONTROLLER
PERIPHERAL INTERFACING -
IV UNIT
www.studentsfocus.com
8255 Programmable Peripheral
! Introduction
Interface
! 8255 is a widely used programmable, parallel I/O device
!Can be programmed to transfer data under various conditions,
from simple I/O to interrupt I/O
!Has 24 I/O pins that can be grouped in two 8 bit parallel
ports: A and B, with the remaining eight bits as port C.
!The 8 bits of port C can be used as individual bits or be
grouped in two 4-bit ports: CUPPER(CU) and CLOWER(CL)
Port A
CU
CL
Port B
2/17/2008
• Two Modes
– Bit Set/Reset (BSR) mode is used to set or reset the bits in
port C
– I/O mode
• Mode 0
• Mode 1
• Mode 2
"In mode 0 all ports function as simple I/O ports
" Mode 1 is a handshake mode whereby ports A and/or B
use bits from port C as handshake signals.
" Handshake mode (two types of I/O data transfer)
status check & interrupt
" In Mode 2, port A can be set up for bidirectional data
transfer using handshake signals from port C and port B
can be set up in either Mode 0 or Mode1.
www.studentsfocus.com
Modes of 8255
D7 D6 D5 D4 D3 D2 D1 D0
0/1
Pin Configuration
www.studentsfocus.com
Signals of 8255
www.studentsfocus.com
8255 block diagram
2/17/2008
www.studentsfocus.com
• The CS signal is the master chip select & A1 and A0 specify one
of the I/O ports
CS A1 A0 Selected
0 0 0 Port A
0 0 1 Port B
0 1 0 Port C
0 1 1 Control
Register
1 X X 8255 is not
selected
www.studentsfocus.com
• Group A and Group B controls : These block receive control
from the CPU and issues commands to their respective ports.
b) Port B: This has an 8 bit latched / buffered O/P and 8 bit input
latch. It can be programmed in mode 0, mode1.
c) Port C : This has an 8 bit latched input buffer and 8 bit out put
latched/buffer. This port can be divided into two 4 bit ports
and can be used as control signals for port A
and port B. it can be programmed in mode 0.
2/17/2008
www.studentsfocus.com
Expanded version of the control logic
and I/O ports
CONTROL WORD
• The contents of the control register called the control word
specify an I/O function for each port.
• This register can be accessed to write a control word when A0
& A1 are at logic 1
• Control word register can only be written into and no read
operation of the CW register is allowed.
• Bit D7 of the control register specifies either the I/O function
or the Bit Set/Reset function.
• If Bit D7 =1, bits D6- D1 determine I/O functions in various
mode
• If bit D7 = 0, port C operates in the Bit Set/Reset(BSR)mode.
www.studentsfocus.com
www.studentsfocus.com
BSR (Bit Set/Reset) Mode
www.studentsfocus.com
Mode 0: Simple Input or Output
• In this mode, ports A and B are used as two simple 8 bit ports
and port C as two 4 bit ports.
• Each port can be programmed to function as simply an input
port or an output port.
• The input/output features in Mode 0 are
– Outputs are latched
– Input are not latched
– 16 different Input/output configurations possible
www.studentsfocus.com
Mode 1: Input or Output with
handshake
! The features of this mode are
◦ Two ports (A and B) function as 8 bit I/O ports. They
can be configured either as input or output ports.
◦ Each port uses three lines from port C as handshake
signals. The remaining two lines of port C can be used
for simple I/O functions.
◦ Input and output data are latched
◦ Interrupt logic is supported.
www.studentsfocus.com
• IBF(Input Buffer Full):This signal is an acknowledgement by
the 8255A to indicate that the input latch has received the data
byte. This is reset when the MPU reads the data
www.studentsfocus.com
Mode 1: Output Control Signals
! OBF (Output buffer full ) – This status signal, whenever falls
to low, indicates that CPU has written data to the specified
output port. The OBF flip-flop will be set by a rising edge of
WR signal and reset by a low going edge at the ACK input.
www.studentsfocus.com
2/17/2008
www.studentsfocus.com
CONTROL WORD FORMATS
Mode 1 Input Mode 1 Output
www.studentsfocus.com
Mode 2: Bidirectional Input/Output
www.studentsfocus.com
REFERENCES
2/17/2008
www.studentsfocus.com
Introduction
8254 programmable interval timer/counter
Introduction(cont.)
• A 16 bit count is loaded in its register and, on command,
begins to decrement the count until it reaches 0
• At the end of count it generates a pulse that can be used to
interrupt the MPU
• The counter can count either in binary or BCD.
• 8254 is an upgraded version of 8253 and they are pin-
compatible
www.studentsfocus.com
SPECIFICATIONS
www.studentsfocus.com
UNIT-5
STEPPER MOTOR CONTROLLER
www.studentsfocus.com
10.ANALOG TO DIGITAL CONVERTER
www.studentsfocus.com
11 DIGITAL TO ANALOG CONVERTER
(a)SQUARE WAVE GENERATOR
DELAY PROGRAM
www.studentsfocus.com
11 DIGITAL TO ANALOG CONVERTER
(b)TRIANGULAR WAVE GENERATOR
MEMORY LABEL MNEMONICS OPCODE COMMENTS
8000 START MVI A,80 3E,80 A!80
8002 OUT 43 D3,43 OUT THROUGH A
8004 L3 MVI A,00 3E,00 A!00
8006 OUT 40 D3,40 OUT THROUGH A
8008 L1 INR A 3C INCREMENT A
8009 OUT 40 D3,40 OUT THROUGH A
800B CPI FF FE,FF COMPARE IMM WITH FF
800D JNZ L1 C2,08,80 JUMP IF NO ZERO TO 8008
8010 MVI A,FF 3E,FF A!FF
8012 OUT 40 D3,40 OUT THROUGH A
8014 L2 DCR A 3D DECREMENT A
8015 OUT 40 D3,40 OUT THROUGH A
8017 CPI 40 FE,00 COMPARE IMM WITH 00
8019 JNZ L2 C2,14,80 JUMP TO 8014
801C JMP L3 C3,04,80 JUMP TO 8004
www.studentsfocus.com
11 DIGITAL TO ANALOG CONVERTER
(C)SAWTOOTH GENERATOR
www.studentsfocus.com
www.studentsfocus.com