8155 Static Ram With I/O Ports and Timer
8155 Static Ram With I/O Ports and Timer
D0-D7 Data Bus. These are 8-bit bi-directional buses, connected to 8086 data
bus for transferring data.
CS’ Chip Select. A "low" on this input pin enables the communication
between the 8255 and the CPU.
RD’ Read. A "low" on this input pin enables 8255 to send the data or status
Information to the CPU on the data bus. In essence, it allows the CPU
to "read from" the 8255.
WR’ Write. A "low" on this input pin enables the CPU to write data or
control words into the 8255.
A0 -A1 Port Select 0 and Port Select 1. These input signals, in conjunction
with the RD’ and WR’ inputs, control the selection of one of the three
ports or the control word register. They are normally connected to the
least significant bits of the address bus (A0 and A1).
A1 A0 SELECTION
0 0 PORT A
0 1 PORT B
1 0 PORT C
1 1 CONTROL REGISTER
RESET Reset. A "high" on this input initializes the control register to 9BH
and all ports (A, B, C) are set to the input mode.
PA0-PA7 It is the 8-bit bi-directional I/O pins used to send the data to peripheral
or to receive the data from peripheral.
PB0-PB7 Similar to PA
PC0-PC7 This is also 8-bit bidirectional I/O pins. These lines are divided into
two groups.
PC0 to PC3 (Lower Group) and
PC4 to PC7 (Higher group)
MODES OF OPERATION OF 8255 PPI
D0, D1, D3, D4 are assigned for lower port C, port B, upper port C and port A
respectively. When these bits are 1,the corresponding port acts as an input port.
D2 is used for mode selection of Group B (port B and lower port C). When D2 = 0,
mode 0 is selected and when D2 = 1, mode 1 is selected.
D5& D6 are used for mode selection of Group A ( port A and upper port C). The
selection is done as follows:
D6 D5 Mode
0 0 Mode 0
0 1 Mode 1
1 X Mode 2
As it is I/O mode, D7 = 1
Mode 2
Only group A can be initialized in this mode. Port A can be used for bidirectional
handshake data transfer. This means that data can be input or output on the same
eight lines (PA0 - PA7). Pins PC3 - PC7 are used as handshake lines for port A.
The remaining pins of port C (PC0 - PC2) can be used as input/output lines if
group B is initialized in mode 0 or as handshaking for port B if group B is
initialized in mode 1. In this mode, the 8255 may be used to extend the system bus
to a slave microprocessor or to transfer data bytes to and from a floppy disk
controller. Acknowledgement and handshaking signals are provided to maintain
proper data flow and synchronization between the data transmitter and receiver.
Q Write the control word for using 8255 PPI as Port A as input, Port B as output in
Mode 1.
Ans. Control word = 1 0110100 = B4H
This unit controls the flow of data through the microprocessor. It is enabled only when D is low.
Its data buffer interfaces the external bus of the system with the internal bus of the
microprocessor. The pins A0, RD, and WR are used for command, status or data read/write
operations.
This unit contains registers to store the keyboard, display modes, and other operations as
programmed by the CPU. The timing and control unit handles the timings for the operation of
the circuit.
Scan Counter
It has two modes i.e. Encoded mode and Decoded mode. In the encoded mode, the counter
provides the binary count that is to be externally decoded to provide the scan lines for the
keyboard and display.
In the decoded scan mode, the counter internally decodes the least significant 2 bits and
provides a decoded 1 out of 4 scan on SL0-SL3.
This unit first scans the key closure row-wise, if found then the keyboard debounce unit
debounces the key entry. In case, the same key is detected, then the code of that key is directly
transferred to the sensor RAM along with SHIFT & CONTROL key status.
This unit acts as 8-byte first-in-first-out (FIFO) RAM where the key code of every pressed key
is entered into the RAM as per their sequence. The status logic generates an interrupt request
after each FIFO read operation till the FIFO gets empty.
In the scanned sensor matrix mode, this unit acts as sensor RAM where its each row is loaded
with the status of their corresponding row of sensors into the matrix. When the sensor changes
its state, the IRQ line changes to high and interrupts the CPU.
This unit consists of display address registers which holds the addresses of the word currently
read/written by the CPU to/from the display RAM.
PIN DIAGRAM OF 8279 PKDC
Data Bus Lines, DB0 - DB7 These are 8 bidirectional data bus lines used to transfer the
data to/from the CPU.
CS Chip Select When this pin is set to low, it allows read/write operations,
else this pin should be set to high.
IRQ This interrupt output line goes high when there is data in
the FIFO sensor RAM. The interrupt line goes low with
each FIFO RAM read operation. However, if the FIFO
RAM further contains any key-code entry to be read by the
CPU, this pin again goes high to generate an interrupt to the
CPU.
Vss, Vcc These are the ground and power supply lines of the
microprocessor.
SL0 − SL3 These are the scan lines used to scan the keyboard matrix
and display the digits. These lines can be programmed as
encoded or decoded, using the mode control register.
RL0 − RL7 These are the Return Lines which are connected to one
terminal of keys, while the other terminal of the keys is
connected to the decoded scan lines. These lines are set to 0
when any key is pressed.
SHIFT The Shift input line status is stored along with every key
code in FIFO in the scanned keyboard mode. Till it is
pulled low with a key closure, it is pulled up internally to
keep it high
OUTA0 – OUTA3 These are the output ports for two 16x4 or one 16x8
OUTB0 – OUTB3 internal display refresh registers. The data from these lines
is synchronized with the scan lines to scan the display and
the keyboard.
Input Mode
This mode deals with the input given by the keyboard and this mode is further classified into 3
modes.
Scanned Keyboard Mode − In this mode, the key matrix can be interfaced using either
encoded or decoded scans. In the encoded scan, an 8×8 keyboard or in the decoded scan,
a 4×8 keyboard can be interfaced. The code of key pressed with SHIFT and CONTROL
status is stored into the FIFO RAM.
Scanned Sensor Matrix − In this mode, a sensor array can be interfaced with the
processor using either encoder or decoder scans. In the encoder scan, 8×8 sensor matrix
or with decoder scan 4×8 sensor matrix can be interfaced.
Strobed Input − In this mode, when the control line is set to 0, the data on the return
lines is stored in the FIFO byte by byte.
Output Mode
This mode deals with display-related operations. This mode is further classified into two output
modes.
Display Scan − This mode allows 8/16 character multiplexed displays to be organized as
dual 4-bit/single 8-bit display units.
Display Entry − This mode allows the data to be entered for display either from the
right side/left side.
8251A USART
(UNIVERSAL SYNCHRONOUS ASYNCHRONOUS RECEIVER TRANSMITTER)
RESET A "High" on this input forces the 8251 into "reset status." The
device waits for the writing of "mode instruction." The min.
reset width is six clock inputs during the operating status
of CLK.
RD’ This is the "active low" input terminal which receives a signal
for reading receive data and status words from the 8251.
CS’ This is the "active low" input terminal which selects the 8251 at
low level when the CPU accesses. Note: The device won’t be in
"standby status"; only setting CS’ = High.
TXRDY This is an output terminal which indicates that the 8251is ready
to accept a transmitted data character. But the terminal is
always at low level if CTS = high or the device was set in "TX
disable status" by a command. Note: TXRDY status word
indicates that transmit data character is receivable, regardless of
CTS or command. If the CPU writes a data character, TXRDY
will be reset by the leading edge or WR signal.
TXEMPTY This is an output terminal which indicates that the 8251 has
transmitted all the characters and had no data character. In
"synchronous mode," the terminal is at high level, if transmit
data characters are no longer remaining and sync characters are
automatically transmitted. If the CPU writes a data character,
TXEMPTY will be reset by the leading edge of WR signal.
Note : As the transmitter is disabled by setting CTS "High" or
command, data written before disable will be sent out. Then
TXD and TXEMPTY will be "High". Even if a data is written
after disable, that data is not sent out and TXE will be
"High".After the transmitter is enabled, it sent out. (Refer to
Timing Chart of Transmitter Control and Flag Timing)
TXC This is a clock input signal which determines the transfer speed
of transmitted data. In "synchronous mode," the baud rate will
be the same as the frequency of TXC. In "asynchronous mode",
it is possible to select the baud rate factor by mode instruction.
It can be 1, 1/16 or 1/64 the TXC. The falling edge of TXC
shifts the serial data out of the 8251.
RXC This is a clock input signal which determines the transfer speed
of received data. In "synchronous mode," the baud rate is the
same as the frequency of RXC. In "asynchronous mode," it is
possible to select the baud rate factor by mode instruction. It
can be 1, 1/16, 1/64 the RXC.
Mode instruction is used for setting the function of the 8251. Mode instruction will
be in "wait for write" at either internal reset or external reset. That is, the writing of
a control word after resetting will be recognized as a "mode instruction."
Mode set word for Asynchronous mode
Mode set word for Synchronous mode
Q. Write a mode set word to use 8251 in asynchronous mode with 1 start/stop bits,
with 7 character length.
Q. Write the command instruction word to use the transmitter section for forced
break detection and hunt mode.
Data Bus Buffer: This tri-state, bi-directional, 8-bit buffer is used to interface the
8253/54 to the system data bus. The Data bus buffer has three basic functions.
1. Programming the modes of 8253/54.
2. Loading the count registers.
3. Reading the count values.
Read/Write Control Logic: The Read/Write logic has five signals : RD’, WR’,
CS’ and the address lines A0 and A1. In the peripheral I/O mode, the RD’ and
WR’ signals are connected to IOR and IOW, respectively. In memory-mapped I/O,
these are connected to MEMR and MEMW. Address lines A0 and A1 of the CPU
are usually connected to lines A0 and A1 of the 8253/54, and CS’ is tied to a
decoded address. The control word register and counters are selected according to
the signals on lines A0 and A1.
A1 A0 Selection
0 0 Counter 0
0 1 Counter 1
1 0 Counter 2
1 1 Control Register
Control Word Register: This register is accessed when lines A0 and A1 are at
logic 1. It is used to write a command word which specifies the counter to be used
(binary or BCD), its mode, and either a read or write operation.
Counters : These three functional blocks are identical in operation. Each counter
consists of a single, 16 bit, pre-settable, down counter. The counter can operate in
either binary or BCD and its input, gate and output are configured by the selection
of modes stored in the control word register. The counters are fully independent.
The programmer can read the contents of any of the three counters without
disturbing the actual count in process.
PIN DIAGRAM OF 8253 PIT
a) Normal Operation:
1) The output will be initially low after the mode set operation.
2) After the count is loaded into the selected count register the output will remain
low and the counter will count.
3) When the terminal count is reached the output will go high and remain high
until the selected count is reloaded.
b) Gate Disable
1) Gate = 1 enables counting.
2) Gate = 0 disables counting.
Note : Gate has no effect on OUT.
c) New Count
If a new count is written to the counter, it will be loaded on the next CLK pulse
and counting will continue from the new count
a) Normal operation
1) The output will be initially high
2) The output will go low on the CLK pulse following the rising edge at the gate
input.
3) The output will go high on the terminal count and remain high until the next
rising edge at the gate input.
b) Retriggering
The one shot is retriggerable, hence the output will remain low for the full count
after any rising edge of the gate input.
c) New count
If the counter is loaded during one shot pulse, the current one shot is not affected
unless the counter is retriggered. If retriggered, the counter is loaded with the new
count and the one-shot pulse continues until the new count expires.
MODE 2 : Rate generator
This mode functions like a divide by-N counter.
a) Normal Operation
1) The output will be initially high.
2) The output will go low for one clock pulse before the terminal count.
3) The output then goes high, the counter reloads the initial count and the process
is repeated.
4) The period from one output pulse to the next equals the number of input counts
in the count register.
b) Gate Disable
1) If Gate = 1 it enables a counting otherwise it disables counting (Gate = 0 ).
2) If Gate goes low during an low output pulse, output is set immediately high.
A trigger reloads the count and the normal sequence is repeated.
c) New count The current counting sequence does not affect when the new count
is written. If a trigger is received after writing a new count but before the end of
the current period, the new count will be loaded with the new count on the next
CLK pulse and counting will continue from the new count. Otherwise, the new
count will be loaded at the end of the current counting cycle.
Note : In mode 2, a count of 1 is illegal.
MODE 3 : Square Wave Rate Generator
a) Normal operation
1) Initially output is high.
2) For even count, counter is decremented by 2 on the falling edge of each clock
pulse. When the counter reaches terminal count, the state of the output is changed
and the counter is reloaded with the full count and the whole process is repeated.
3) If the count is odd and the output is high the first clock pulse (after the count
is loaded) decrements the count by 1. Subsequent clock pulses decrement the clock
by 2. After timeout, the output goes low and the full count is reloaded. The first
clock pulse (following the reload) decrements the count by 3 and subsequent clock
pulse decrement the count by two. Then the whole process is repeated. In this way,
if the count is odd, the output will be high for (n+1)/2 counts and low for (n-1)/2
counts.
b) Gate Disable
If Gate is 1 counting is enabled otherwise it is disabled. If Gate goes low while
output is low, output is set high immediately. After this, When Gate goes high, the
counter is loaded with the initial count on the next clock pulse and the sequence is
repeated.
c) New Count
The current counting sequence does not affect when the new count is written. If a
trigger is received after writing a new count but before the end of the current half-
cycle of the square wave, the counter will be loaded with the new count on the next
CLK pulse and counting will continue from the new count. Otherwise, the new
count will be loaded at end of the current half-cycle.
MODE 4 : Software Triggered Strobe.
a) Normal operation
1) The will be initially high
2) The output will go low for one CLK pulse after the terminal count (TC).
b) Gate Disable
If Gate is one the counting is enabled otherwise it is disabled. The Gate has no
effect on the output.
c) New count
If a new count is written during counting, it will be loaded on the next CLK pulse
and counting will continue from the new count. If the count is two byte then
1) Writing the first byte has no effect on counting.
2) Writing the second byte allows the new count to be loaded on the next CLK
pulse.
MODE 5 : Hardware Triggered Strobe (Retriggerable).
a) Normal operation
1) The output will be initially high.
2) The counting is triggered by the rising edge of the Gate.
3) The output will go low for one CLK pulse after the terminal count (TC).
b) Retriggering
If the triggering occurs on the Gate input during the counting, the initial count is
loaded on the next CLK pulse and the counting will be continued until the terminal
count is reached.
c) New count
If a new count is written during counting, the current counting sequence will not
be affected. If the trigger occurs after the new count is written but before the
terminal count, the counter will be loaded with the new count on the next CLK
pulse and counting will continue from there.
Q Write a control word to select counter 2 to operate in Mode 3 for binary
counting