Professional Documents
Culture Documents
Eee 342 Ppi
Eee 342 Ppi
Interfacing
1/20/23 2
Motivation
1/20/23 3
REVISIT I/O Application in previous Lecture
Pull-up
Resistors To mP
Gate
0 1
Toggle switches
1/20/23 4
REVISIT I/O Application in previous Lecture
Pull-up
Resistors To mP
Gate
0 1
Toggle switches
1/20/23 5
Interfacing Bidirectional I/O Port
1/20/23 6
Intel 8255 PPI
The 8255 allows the microprocessor to communicate
with the outside world through three programmable
8-bit wide I/O ports
The PC uses a few 82C55 (in the chip set) to control
the keyboard, speaker, and parallel port
1/20/23 7
8255 PPI Pinout
D0 PA0
. .
.
.
. . . .
. . . .
D7 PA7
PB0 .
WR
.
. .
RD
. .
CS PB7
RESET PC0
.
.
. .
A1
A0 . .
PC7
8255 PPI
1/20/23 8
Important pins of PPI
1/20/23 9
8255 PPI Pinout
3 programmable
8-bit I/O ports: A, B, C
2 Groups
12-bit groups A, B
Data Bus A
A1 A0 Function
0 0 PortA Selected
0 1 PortB Selected
1 0 PortC Selected
1 1 Control Word
Selected
1/20/23 11
Block Diagram of PPI
1/20/23 12
Complete the table and specify functions
A1 A0 RD WR CS
1/20/23 13
Interfacing with 8088 CPU
D0 D0 PA0
CPU . . .
.
data . . .
.
bus . . .
.
D7 D7 PA7
WR’ WR PB0
.
A2 CPU .
CPU Address bus
lines .
A3 RD’ RD .
.
A4 .
CS PB7
A5
A6 RESET RESET PC0 .
A7 CPU . .
A1 A1
IO/M’ Address . .
lines .
A0 A0
PC7
8255 PPI
1/20/23 14
82C55 connected to the 80386SX so that it functions at 8-bit I/O port
addresses C0H (port A), C2H (port B), C4H (port C), and C6H
(command register).
1/20/23 15
Example
Draw a diagram to connect 82C55 to a 8088 so that it
functions at 8-bit I/O port addresses 80H (port A), 82H
(port B), 84H (port C), and 86H (command register).
1/20/23 16
Example
Draw a decoder circuit to connect 82C55 to a 8088
such that it functions at 8-bit I/O port addresses A0H
(port A), A1H (port B), A2H (port C), and A3H
(command register).
1/20/23 17
Control Word Register
7 6 5 4 3 2 1 0
PortC
Modes (PC3...PC0) I/O
1/20/23 18
Control Word Register
82C55 is programmed through its control register,
command Byte A or command Byte B
1/20/23 19
Control Word Register
1/20/23 20
Groups of PPI Lines
Group A consists on eight pins of PortA and upper four
pins of PortC (PC4 to PC7)
1/20/23 21
8255 Modes
Mode 0 (for groups A & B)- the most commonly used mode:
All 12 bits of the group are simple inputs or simple
latched outputs Data
Data
Mode 1 (for groups A & B)- is used occasionally to provide
handshaking to an I/O device and operate asynchronously with
the device. Most Port C bits are dedicated for handshake
functions for the operation. A few are controlled separately
using the Command byte B format for handshaking I/O.
Data
Control, e.g. Busy,
Strobe, etc.
Mode 2 (for group A only- Group B not used)- is a bidirectional
mode for Port A only (Port B is not used). Port C provides
handshaking signals.
Group I/O mode
Deals with Group A and Group B I/O
Activated with placing logic 1 in bit7 of control word
register
FOR PORT A
All the lines of Port A can be configured either input or
output
For group A, all the four lines of Port C (PC7…PC4) can be
configured either input or output
FOR PORT B
All the lines of Port B can be configured either input or
output
For group B, all the four lines of Port C (PC3…PC0) can be
configured either input or output
1/20/23 23
Mode 0: Basic I/O mode
1/20/23 24
Examples of configuring Basic I/O mode
Configure all lines of Group A as ‘input’ and all lines
of Group B as ‘output’.
Configure PortA as ‘input’, PortB as ‘output’ and
PortC as ‘output’
In Group A, configure PortA as ‘output’, and PortC as
‘input’
In Group B, configure PortB as ‘input’, and PortC as
‘output’
1/20/23 25
Bit-select mode
Activated by placing logic 0 in bit7 of control word
register
Selects direction of individual bit of PortC
0 X X X
Bit
selection
1/20/23 26
Programming the 82C55
To program the command
register of the 82C55 and select
operation use command byte A
For example, to program all the
ports as outputs and in mode 0
(the most common mode) use:
MOV AL,80H
MOV DX,COMMAND_PORT
OUT DX,AL
Programming the 82C55
Example. Program Command
Register of 82C55 such that
port A acts as input and port B
acts as output port.
Command Byte A
1001 X00X
Mode 0 Application: 7-Segement Display
Segment
Driver Common
7-Segement Display
CA Vcc
Anode
Cathode
Select Segments: Switched Resistors to GND
CC
Select Segments: Switched Resistors to Vcc
GND
7-Segement Display
Anode
Cathode
n=8
Digits
Sequentially
Turn ON one digit at a time
0 turns digit
B: O/P Port: digit ON Vcc
Select # Displayed
B: O/P Port: 1 digit
Select digit . . . . . .
GND
To be displayed
Programming Part
Set the PORT A and PORT B as output ports
Programming Part
The procedure to multiplex the displays is listed in assembly language
; Program the 82C55 for Port A and Port B are output ports in mode 0
MOV AL, 80H ; 80H Data into AL
MOV DX, 703H ; Address of Command Port into DX 8 bytes of
OUT DX, AL ; Write 80H into Command Port
; ; to program PPI Digit Data
; An assembly language procedure that multiplexes the 8-digit display.
MEM+7 In memory
MS Digit
; This procedure must be called often enough for the display to appear stable .
DISPPROC NEAR USES AX BX DX SI .
PUSHF BX
MOV BX,8 ;load counter BX with # of display digits .
MEM LS Digit
MOV AH,7FH ;load initial digit selection pattern to enable MS digit (01111111)
MOV SI,OFFSET MEM - 1 ;Load SI with offset (MEM) - 1
MOV DX,701H ;address Port B (for Port A: decrement DX)
;Sequentially display all 8 digits starting with MS digit
.REPEAT
MOV AL,AH
OUT DX,AL ;send digit selection pattern to Port B
DEC DX ;Address Port A (to send Digit Data)
MOV AL,[BX+SI] ;Load digit data from memory into AL
OUT DX,AL ;send digit data to Port A
CALL DELAY ;wait 1.0 ms leaving displayed digit ON
ROR AH,1 ;adjust selection pattern to point to next digit
INC DX ;Address port B
DEC BX ;decrement counter for data of next digit.
.UNTIL BX == 0
POPF
Procedure for 1 ms delay, e.g. a loop of instruc
RET i.e. digit remains ON for 1 ms before moving to
DISPENDP
Delay
Interfacing of LCD using PPI
44780 LCD Controller
Controls alphanumeric printing
on LCD
Has 8-bit and 4-bit interface
characters to be printed
41
Interfacing of LCD using PPI
LCD Pin Description
Pin No Function Name
1 Ground (0V) Ground
2 Supply voltage; 5V (4.7V – 5.3V) Vcc
3 Contrast adjustment; through a variable resistor VEE
4 Selects command register when low; and data register Register
when high Select
5 Low to write to the register; High to read from the register Read/write
6 Sends data to data pins when a high to low pulse is given Enable
7 DB0
8 DB1
9 DB2
10 DB3
8-bit data pins
11 DB4
12 DB5
13 DB6
14 DB7
15 Backlight VCC (5V) Led+
16 Backlight Ground (0V) Led-
1/20/23 43
LCD PPI Interfacing
1/20/23 44
LCD PPI Interfacing
1/20/23 45
LCD PPI Interfacing
This illustrates an 8-bit interface. If a 4-bit interface is
desired, D4–D7 pins are used for the data where the data
must be formatted with the high nibble first, followed by the
low nibble.
Control pins
• RS (register select) input selects data (RS = 0) or
instructions (RS = 1).
1/20/23 46
LCD PPI Interfacing
In order to program the DMC-20481 we must first initialize it.
Initialization is accomplished via the following steps:
1/20/23 47
LCD PPI Interfacing
1/20/23 48
LCD PPI Interfacing
1/20/23 49
LCD PPI Interfacing
1/20/23 50
LCD PPI Interfacing (Practice)
1/20/23 51
LCD PPI Interfacing (Practice)
Write a program to clear the display
1/20/23 52
LCD PPI Interfacing (Writing)
Write a program for following interfacing to write an ASCII
character to LCD
1/20/23 53
LCD PPI Interfacing (Writing)
1/20/23 54
LCD PPI Interfacing (Busy)
1/20/23 55
Motor Interfacing using PPI
• What is A motor?
1/20/23 56
Motor Interfacing using PPI
1/20/23 57
Motor Interfacing using PPI
• Electric Car
• Fans
• Pumps
• Rolling machine
• Electric Cars
• Robotic arms
1/20/23 58
Stepper Motor Interfacing using
PPI
• Stepper motors are DC motors that move in discrete steps
• It rotates in a sequence of discrete steps controlled by sequentially
energizing a set of coils (windings)
1/20/23 59
Stepper Motor Interfacing using
PPI
1/20/23 60
Stepper Motor Interfacing using
PPI
1/20/23 61
Stepper Motor Interfacing using
PPI
1/20/23 62
Stepper Motor Interfacing using PPI (Full Step
Operation)
1/20/23 63
Stepper Motor Interfacing using PPI (Full Step
Operation)
A B C D STEP
0 0 0 1 90
0 0 1 0 90
0 1 0 0 90
1 0 0 0 90
0 0 0 1 90
1/20/23 64
Stepper Motor Interfacing using PPI (Full Step
Operation)
A B C D STEP
0 0 1 1 90
0 1 1 0 90
1 1 0 0 90
1 0 0 1 90
0 0 1 1 90
1/20/23 65
Stepper Motor Interfacing using PPI (Half Step Operation)
A B C D STEP
0 0 1 1 45
0 0 1 0 45
0 1 1 0 45
0 1 0 0 45
1 1 0 0 45
1 0 0 0 45
1 0 0 1 45
0 0 0 1 45
1/20/23 66
Stepper Motor Interfacing using PPI (Full Step
Operation) Darlington pairs
for driving
high load currents
1/20/23 67
Stepper Motor Interfacing using PPI
1/20/23 68
Stepper Motor Interfacing using PPI (Full Step
Operation)
33H = 00110011
66H = 01100110
CCH = 11001100
CX Positive: Rotate Anti-clockwise
99H = 10011001
Anti-Clockwise Clockwise
ROL ROR
1/20/23 69
Stepper Motor Interfacing EXAMPLE 1
1/20/23 70
Stepper Motor Interfacing EXAMPLE 2
1/20/23 71