All 8251 8255 852
All 8251 8255 852
Peripheral Interfacing
S.Sayeekumar , AP/RMDEEE
8251
• The 8251A is a programmable serial
communication interface chip designed for
synchronous and asynchronous serial
data communication.
• It supports the serial transmission of data.
• It is packed in a 28 pin DIP.
Pin details
Architecture
Arch - details
• The functional block diagram of 825 1A
consists five sections.
They are:
• Read/Write control logic
• Transmitter
• Receiver
• Data bus buffer
• Modem control.
Read/Write control logic
• The Read/Write Control logic interfaces the
8251A with CPU, determines the functions of the
8251A according to the control word written into
its control register.
• It monitors the data flow.
• This section has three registers and they are
control register, status register and data buffer.
• The active low signals RD, WR, CS and
C/D(Low) are used for read/write operations with
these three registers.
Read/Write control logic
• When C/D(low) is high, the control register is
selected for writing control word or reading
status word.
• When C/D(low) is low, the data buffer is selected
for read/write operation.
• When the reset is high, it forces 8251A into the
idle mode.
• The clock input is necessary for 8251A for
communication with CPU and this clock does not
control either the serial transmission or the
reception rate.
Transmitter
• The transmitter section accepts parallel data
from CPU and converts them into serial data.
• The transmitter section is double buffered, i.e., it
has a buffer register to hold an 8-bit parallel data
and another register called output register to
convert the parallel data into serial bits.
• When output register is empty, the data is
transferred from buffer to output register. Now
the processor can again load another data in
buffer register.
Transmitter
• If buffer register is empty, then TxRDY is goes to
high.
• If output register is empty then TxEMPTY goes to
high.
• The clock signal, TxC (low) controls the rate at
which the bits are transmitted by the USART.
• The clock frequency can be 1,16 or 64 times the
baud rate.
Receiver
• The receiver section accepts serial data and
convert them into parallel data
• The receiver section is double buffered, i.e., it
has an input register to receive serial data and
convert to parallel, and a buffer register to hold
the parallel data.
• When the RxD line goes low, the control logic
assumes it as a START bit, waits for half a bit
time and samples the line again.
• If the line is still low, then the input register
accepts the following bits, forms a character and
loads it into the buffer register.
Receiver
• The CPU reads the parallel data from the buffer register.
• When the input register loads a parallel data to buffer
register, the RxRDY line goes high.
• The clock signal RxC (low) controls the rate at which bits
are received by the USART.
• During asynchronous mode, the signal
SYNDET/BRKDET will indicate the break in the data
transmission.
• During synchronous mode, the signal SYNDET/BRKDET
will indicate the reception of synchronous character.
Modem control
• The MODEM control unit allows to interface a MODEM to 8251A
and to establish data communication through MODEM over
telephone lines.
• This unit takes care of handshake signals for MODEM interface.
• The 825 1A can be either memory mapped or I/O mapped in the
system.
• 8251A in I/O mapped in the system is shown in the figure.
• Using a 3-to-8 decoder generates the chip select signals for I/O
mapped devices.
• The address lines A4, A5 and A6 are decoded to generate eight chip
select signals (IOCS-0 to IOCS-7) and in this, the chip select signal
IOCS-2 is used to select 8251A.
• The address line A7 and the control signal IO / M(low) are used as
enable for decoder.
• The address line A0 of 8085 is connected to C/D(low) of 8251A to
provide the internal addresses.
Modem control
• The data lines D0 - D7 are connected to D0 - D7 of the
processor to achieve parallel data transfer.
• The RESET and clock signals are supplied by the
processor. Here the processor clock is directly
connected to 8251A. This clock controls the parallel data
transfer between the processor and 8251A.
• The output clock signal of 8085 is divided by suitable
clock dividers like programmable timer 8254 and then
used as clock for serial transmission and reception.
Modem control
• The TTL logic levels of the serial data lines and the
control signals necessary for serial transmission and
reception are converted to RS232 logic levels using
MAX232 and then terminated on a standard 9-pin D-
.type connector.
• In 8251A the transmission and reception baud rates can
be different or same.
• The device which requires serial communication with
processor can be connected to this 9-pin D-type
connector using 9-core cable
• The signals TxEMPTY, TxRDY and RxRDY can be used
as interrupt signals to initiate interrupt driven data
transfer scheme between processor and 8251
Modem control
• The CPU reads the parallel data from the buffer register.
• When the input register loads a parallel data to buffer
register, the RxRDY line goes high.
• The clock signal RxC (low) controls the rate at which bits
are received by the USART.
• During asynchronous mode, the signal
SYNDET/BRKDET will indicate the break in the data
transmission.
• During synchronous mode, the signal SYNDET/BRKDET
will indicate the reception of synchronous character.
8251 mode register
7 6 5 4 3 2 1 0 Mode register
• PPI
Programmable Peripheral
Interface
20
Intel 8255 PPI
PPI – Programmable Peripheral Interface
It is an I/O port chip used for interfacing I/O
devices with microprocessor
Very commonly used peripheral chip
Knowledge of 8255 essential for students in the
Microprocessors lab for Interfacing experiments
21
About 82C55
• The 82C55 is a popular interfacing component, that
can interface any TTL-compatible I/O device to a
microprocessor.
• It is used to interface to the keyboard and a parallel
printer port in PCs (usually as part of an integrated
chipset).
• Requires insertion of wait states if used with a
microprocessor using higher that an 8 MHz clock.
• PPI has 24 pins for I/O that are programmable in
groups of 12 pins and has three distinct modes of
operation.
82C55 : Pin Layout
8255 Control Word
Basic Mode Definitions and Bus
Int
• Mode 0
– Basic I/O
• Mode 1
– Strobe I/O
• Mode 2
– Bi-Dir Bus
Programming 8255
8255 has three operation modes: mode 0, mode 1, and mode 2
11-26
27
8255 PPI contd.
3 ports in 8255 from user’s point of view
- Port A, Port B and Port C.
Port C composed of two independent 4-bit ports
- PC7-4 (PC Upper) and PC3-0 (PC Lower)
A1 A0 Selected port
0 0 Port A
0 1 Port B
1 0 Port C
1 1 Control port
28
8255 40 pin DIP
7404 A0
M/IO*
Reset
In this mode, ports A, B are used as two simple 8-bit I/O ports
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 as follows.
31
8255 PPI Contd.
Mode 1: Input or Output with Handshake
33
8255 Handshake signals
34
8255 Handshake signals Contd.
36
8255 MD Control word
Control port having Mode Definition (MD) control word
1 M2A M1A I/P A I/P CU M1B I/P B I/P CL
Means Mode
1 - PCU as input 1 -PCL as input
Definition
control word 0 - PCU as output 0 -PCL as output
1 - PA as input 1 - PB as input
M2A M1A 0 - PA as output 0 - PB as output
0 0 Port A in Mode 0 1 – Port B in Mode 1
0 1 Port A in Mode 1 0 – Port B in Mode 0
1 0/1 Port A in Mode 2
37
8255 MD Control word Contd.
Ex. 1: Configure Port A as i/p in Mode 0, Port B as o/p in
mode 0, Port C (Lower) as o/p and Port C (Upper) as i/p
ports.
Required MD control word:
1 0 0 1 1 0 0 0 = 98H
MD control PC Lower as o/p
PA in Mode 0 PB as o/p Reqd. instrns.
PA as i/p PB in Mode 0 MOV AL, 98H
PC Upper as i/p OUT 7FH, AL
38
8255 MD Control word Contd.
Ex. 2: Configure Port A as i/p in Mode 1, Port B as o/p in
mode 1, Port C7-8 as i/p ports. (PC5-0 are handshake lines,
some i/p lines and others o/p. So they are shown as X)
Required MD control word:
1 0 1 1 1 1 0 X = BCH or BDH
MD control PC3-0 as don’t care
PA in Mode 1 PB as o/p Reqd. Instrns.
PA as i/p PB in Mode 1 MOV AL,BCH
PC Upper(C7-8) as i/p OUT 7FH, AL
39
8255 Contd.
There are 2 control words in 8255
Mode Definition (MD) Control word and
Port C Bit Set / Reset (PCBSR) Control Word
40
8255 MD Control word Contd.
Ex. 3:Configure Port A in Mode 2, Port B as o/p in mode 1.
(PC5-0 are handshake lines for Port A and PC2-0 are
handshake signals for port B)
Required MD control word:
1 1 0 X X 1 0 X = C4H / C5H..
MD control PC3-0 as handshake
PA in Mode 2 PB as o/p Reqd. instrns.
PA bidirectional PB in Mode 1 MOV AL, C4H
PC7-0 as handshake OUT 7FH, AL
41
8255 PCBSR Control word
Control port having Port C Bit Set / Reset control word
0 X X X SB2 SB1 SB0 S/R*
Select bit of PC 1 - Set to 1
PC bit set
Don’t to be set / reset 0 - Reset to 0
/ reset
cares 0 0 0 Bit 0 of Port C
control
word 0 0 1 Bit 1 of Port C
:
:
1 1 1 Bit 7 of Port C
42
8253 / 8254 Timer
• To program a given counter to divide the
CLK input frequency, one must send the
divisor to that specific counter’s register.
• Although all three counters share the same
control register, the divisor registers are
separate for each counter
• Example: given the port addresses for
8253/54: Counter 0: 94H Counter 1:
95H
Counter 2: 96H Engr 4862 Microprocessors
Control Reg: 97H
8253 / 8254 Timer
• Task1: program counter 0 for binary counter
for mode 3 to divide CLK0 by number 4282
(BCD)
MOV AL, 0011 0111B
OUT 97H, AL
MOV AX, 4282H (BCD needs H)
OUT 94H, AL (Low Byte)
MOV AL, AH
OUT 94H, AL (High Byte)
• OUT0 = CLK0 /Engr
42824862 Microprocessors
Shape of the 8253/54 Output
• Given CLK = 1.193 MHz, the clock period of
input frequency is 838 ns
• If the number N loaded into the counter is
even, both high and low pulse are the same
length, which is N/2 * 838 ns
• If the number N loaded into the counter is
odd, the high pulse is (N+1)/2 * 838 ns and
the low pulse is (N–1)/2 * 838 ns
• If N is odd, the high portion of the output
square wave is slightly wider than the low
portion Engr 4862 Microprocessors
8253/54 Operation Modes
• Mode 0: Interrupt on terminal count
– The output is initially low, and remain low for the
duration of the count if GATE=1. When the
terminal count is reached, the output will go
high and remain high until a new control word
or new count number is loaded
• Width of low pulse = N * T, where T is clock period
– Example: GATE=1 and CLK = 1 MHz
Clock count N = 1000
John Uffenbeck
The 80x86 Family: Design, Copyright ©2002 by Pearson Education, Inc.
Upper Saddle River, New Jersey 07458
Programming, and Interfacing, 3e All rights reserved.
FIGURE 9-9 Example illustrating the difference between the rotate-on-nonspecific-EOI command and the rotate-on-specific-
EOI command.
Modes
• Fully Nested mode
• Special Fully Nested mode
• Nonspecific Rotating
• Specific Rotating
• Special Mask
• Polling
FIGURE 9-11 8259A initialization control word format. (Courtesy of Intel Corporation.)
John Uffenbeck
The 80x86 Family: Design, Copyright ©2002 by Pearson Education, Inc.
Upper Saddle River, New Jersey 07458
Programming, and Interfacing, 3e All rights reserved.
Features of 8279
The important features of 8279 are,
• Simultaneous keyboard and display operations.
• Scanned keyboard mode.
• Scanned sensor mode.
• 8-character keyboard FIFO.
• 1 6-character display.
• Right or left entry 1 6-byte display RAM.
• Programmable scan timing.
Pin details
000DDMMM
Mode set: Opcode 000.
DD sets displays mode.
MMM sets keyboard mode.
MMM
100ZAAAA
87
8237 pins
CLK: System clock
CS΄: Chip select (decoder output)
RESET: Clears registers, sets mask register
READY: 0 for inserting wait states
HLDA: Signals that the μp has relinquished buses
DREQ3 – DREQ0: DMA request input for each channel
DB7-DB0: Data bus pins
IOR΄: Bidirectional pin used during programming
and during a DMA write cycle
IOW΄: Bidirectional pin used during programming
and during a DMA read cycle
EOP΄: End of process is a bidirectional signal used as input to terminate
a
DMA process or as output to signal the end of the DMA transfer
A3-A0: Address pins for selecting internal registers
A7-A4: Outputs that provide part of the DMA transfer address
HRQ: DMA request output
DACK3-DACK0: DMA acknowledge for each channel.
AEN: Address enable signal
ADSTB: Address strobe
MEMR΄: Memory read output used in DMA read cycle
MEMW΄: Memory write output used in DMA write cycle
88
8237 pin
Diagram
89
A 8237 DMA application
DMA ARCHITECTURE
90
8237 registers
• CAR (Current Address Register): holds the 16-bit
memory address used for the DMA transfer (one
for each channel), either incremented or
decremented during the operation
• CWCR (Current Word Count Register): Programs a
channel for the number of bytes (up to 64K)
transferred during a DMA operation
• BA (Base Address) and WC (Word Count): Used
when auto-initialization is selected for a channel, to
reload the CAR and CWCR when DMA is
complete.
• CR (Command Register): Programs the operation
of the controller 91
• MR (Mode Register):
92
• MR (Mask
Register):
• SR (Status
Register): Shows
the status of each
DMA channel
93
8237 Software commands
94
8237 Software commands
Clear First/Last Flip-Flop - This command is executed prior to writing or reading
new address or word count information to the 82C37. This command initializes the
flipflop to a known state (low byte first) so that subsequent accesses to register
contents by the microprocessor will address upper and lower bytes in the correct
sequence.
Set First/Last Flip-Flop - This command will set the flip-flop to select the high byte
first on read and write operations to address and word count registers.
Master Clear - This software instruction has the same effect as the hardware
Reset. The Command, Status, Request, and Temporary registers, and Internal
First/Last Flip-Flop and mode register counter are cleared and the Mask register is
set. The 82C37A will enter the idle cycle.
Clear Mask Register - This command clears the mask bits of all four channels,
enabling them to accept DMA requests.
Clear Mode Register Counter - Since only one address location is available for
reading the Mode registers, an internal two-bit counter has been included to select
Mode registers during read operation. To read the Mode registers, first execute the
Clear Mode Register Counter command, then do consecutive reads until the
desired channel is read. Read order is channel 0 first, channel 3 last. The lower
two bits on all Mode registers will read as ones.
95
8237 block diagram
96
Initiating a DMA transaction
Save the current interrupt status and disable
interrupts by executing the CLI instruction
Disable the channel that will be used for the
transaction
Reset the flip-flop by writing a value of 0X to the
register
Set the Mode Register
Set the Page Register
Set the Offset Register
Set the Block Size Register
Enable the channel that will be used for the
transaction
Restore the interrupt status
97
A/D Interfacing
D/A INTERFACING
DEEPAK.P
D/A Interfacing
• The digital to analog converters convert
binary number into their equivalent
voltages.
• The DAC find applications in areas like
digitally controlled gains, motors speed
controls, programmable gain amplifiers etc.
D/A Interfacing
D/A Interfacing
D/A Interfacing
D/A Interfacing
D/A Interfacing
D/A Interfacing
D/A Interfacing
• AD 7523 8-bit Multiplying DAC : This is a 16 pin
DIP, multiplying digital to analog converter,
containing R-2R ladder for D-A conversion along
with single pole double thrown NMOS switches to
connect the digital inputs to the ladder.