Parallel Interface 6821
Parallel Interface 6821
Parallel Interfacing
Expected Outcomes
Identify the internal registers of MC6821
Design the hardware interface for various I/O devices using MC6821
Develop and write codes using MC6821
NMKNYFKEEUMP
Parallel Interface/Timer
I/O interface using a simple I/O device such as latch or buffer has
its drawbacks
One of them is the circuit design must be reconstructed if a user
decide to change its I/O devices
A dedicated peripheral such as the 68230 (PI/T - Parallel
Interface/Timer)
Its primary function is to provide parallel interface
Its secondary function is a programmable timer
It provides 4 modes of operation with various handshaking and
buffering capabilities
Unidirectional 8-bits
Unidirectional 16-bits
Bidirectional 8-bits
Bidirectional 16-bits
NMKNYFKEEUMP
Parallel Interface/Timer
The programmable timer provides a variety of services
Periodic interrupt generation
Square wave generator
Interrupt after time-out
Elapse time measurement
System watchdog
Since, it is part of 68xxx family, the PI/T is expensive due to its
capability to provide wider functions
A simple 8-bit family can be used in certain cases to provide
parallel I/O interface
PIA 6821 peripheral interface adapter is introduced to give
flexibility in I/O system
NMKNYFKEEUMP
PIA 6821
PIA was initially designed for use in 6800-based system
However, it is widely used in 68000-based system due its flexibility
and cost
Since it is part of 6800 family, additional pin connections are
needed to operate in asynchronous mode
The port A and B may be programmed individually to be an
input or an output – allowing the software to adjust to a new
system requirement
Additional signal lines may be programmed to allow interrupts
and strobe signals for each port
Internal register to allow storage of data temporary thus allowing
to interface with a slower devices such as printer
NMKNYFKEEUMP
Each individual signal line (PA0 through PA7 and PB0 through PB7)
PIA has two port with each port may drive two TTL loads
Vss 1 40 CA1
PA0 2 39 CA2
PA1 3 38 IRQA*
4 37 IRQB*
can be programmed as an input or an output
PA2
PA3 5 36 RS0
PA4 6 35 RS1
PA5 7 34 RESET*
PA6 8 33 D0
PA7 9 32 D1
PB0 10 31 D2
6821
NMKNYFKEEUMP
PB1 11 30 D3
PB2 12 29 D4
PB3 13 28 D5
PB4 14 27 D6
PB5 15 26 D7
PB6 16 25 E
PB7 17 24 CS1
CB1 18 23 CS2*
CB2 19 22 CS0
Vcc 20 21 R/W*
PIA 6821
PIA 6821
PIA has 6 internal registers that can be programmed to its need
Each port has three registers
NMKNYFKEEUMP
PIA 6821
Internal structure of PIA consist of six registers and control unit
PA0
PA1
PA2
IRQA Data Direction Control Register PA3
IRQB Register A (DDRA) A (CRA) PA4
PA5
PA6
D7-D0 PA7
Data Register
A (DRA) CA1
RS0 Control CA2
RS1 Unit PB0
E Control Register PB1
R/W B (CRB) PB2
CS0 PB3
CS1 PB4
CS2 Data Register PB5
Data Direction
Register B (DDRB) B (DRB) PB6
RESET
PB7
CB1
CB1
NMKNYFKEEUMP
Interface With 68000
Since 6821 is operating in synchronous mode, additional pin
connections are required
68000 6821
PA7
PA6
RESET RESET
PA5
A0 RS0 PA4
A1 RS1 PA3
PA2
PA1
PA0
CA1
Address CA2
A3-A23 Decoder PB7
PB6
PB5
VPA* PB4
R/W* PB3
R/W*
E PB2
E
PB1
UDS* CS1 PB0
CB1
VMA* CS2 CB2
NMKNYFKEEUMP
PIA Registers
The address of 6 internal registers of PIA depends on
Address decoder
Data Strobe connection (UDS or LDS)
N DDRA/DRA N+1
A2 RS1
A1 RS0 CRA
N+2 N+3
LDS* CS1 N+4 DDRB/DRB N+5
N DDRA/DRA N+1
A2 RS1
A1 RS0 CRA
N+2 N+3
UDS* CS1 N+4 DDRB/DRB N+5
NMKNYFKEEUMP
PIA Registers
1 1 Control Register B
NMKNYFKEEUMP
PIA Registers
Data Register A (DRA)
bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
Logic 1 in each DDRAi causes the signal line PAi to become output line
Logic 0 in each DDRAi causes the signal line PAi to become input line
For example:
If DDRA = $4C, PA6, PA3 and PA2 are output and others are input
NMKNYFKEEUMP
Control Register
DDRA/
IRQA IRQB CA2 CA2 CA2 CA1 CA1
DRA
0: DDRA is chosen
1: DRA is chosen
NMKNYFKEEUMP
Initialize PIA
Initializing PIA is the most crucial steps in
programming a system using this I/O device Set CRx2=1
Read/Write
Data to DRx
NMKNYFKEEUMP
Initialize PIA
Example : Initialize PIA assuming port A is an output port and port
B is an input port
; Initialize Port A
MOVE.B #0,CRA
MOVE.B #$FF,DDRA
MOVE.B #4,CRA
; Initialize Port B
MOVE.B #0,CRB
MOVE.B #0,DDRB
MOVE.B #4,CRB
NMKNYFKEEUMP
More Examples..
initialized
2K2
PB1 PA1
330R
2K2
PB2 PA2
330R
2K2
PB3 PA3
START MOVE.B DRA,D0 330R
PB4 PA4
2K2
330R
NOT.B D0 330R
PB5 PA5
2K2
BRA START
2K2
PB7 PA7
330R
NMKNYFKEEUMP
More Examples..
Write a program to display a +5V
2K2
PA1
2K2
2K2
c
LOOP MOVE.B DRA,D0 PA5 B d
f
g
b
7448 e
ASL.B #4,D0 PA6 C
g
f e
d
c
MOVE.B D0,DRA dp dp
PA7 D
BRA LOOP
NMKNYFKEEUMP
More Examples..
Write a program to display an +5V
2K2
PA1
2K2
2K2
c
ADDQ.B #1,D0 PA5 B d
7448 e
f
g
b
dp dp
BNE LOOP PA7 D
BRA MAIN
NMKNYFKEEUMP
Self-Test
Exercise
Write as simple program to initialize port A where PA0-PA3 are output
and PA4-PA7 are input
Exercise
If port B is connected to 7-segment display, write a program to
initialize port B. Then, write a program to display downward counter
on port B
Exercise
If PB0 is connected to a low current speaker, write a program to
generate continuous tone with frequency of 1kHz to the speaker
NMKNYFKEEUMP
Self-Test
Exercise
Write a program to meet
+5V
counter
2K2
PA2
counter
a
b
c f b
PA5 B d g
value continuously
dp
PA7 D
NMKNYFKEEUMP