Unit 3 Notes PDF
Unit 3 Notes PDF
o Memory has some signal requirements to write into and read from its registers.
o Similarly the microprocessor initiates a set of signals when it wants to read from and
write into memory.
o The Input/output devices such as keyboards and displays are the communication channels
to the outside world. Latches and buffers are used for I/O interfacing.
The use of peripheral integrated devices simplifies both the hardware circuits and software
considerable. The following are the devices used in interfacing of Memory and General I/O devices:
Where N is number of register and M is the word length, in number of bits. As shown in figure(a)
memory chip has 12 address lines Ao–A11, one chip select (CS), and two control lines, Read (RD) to
enable output buffer and Write (WR) to enable the input buffer.
The internal decoder is used to decoder the address lines. Figure(b) shows the logic diagram of a typical
EPROM (Erasable Programmable Read-Only Memory) with 4096 (4K) register. It has 12 address lines
A0 – A11, one chip select (CS), one read control signal. Since EPROM does not require the (WR)
signal.
EPROM (or EPROMs) is used as a program memory and RAM (or RAMs) as a data memory. When
both, EPROM and RAM are used, the total address space 1 Mbytes is shared by them.
Absolute Decoding:
In the absolute decoding technique the memory chip is selected only for the specified logic level on the
address lines: no other logic levels can select the chip. Below figure the memory interface with absolute
decoding. Two 8K EPROMs (2764) are used to provide even and odd memory banks. Control signals
BHE and Ao are use to enable output of odd and even memory banks respectively. As each memory
chip has 8K memory locations, thirteen address lines are required to address each locations,
independently. All remaining address lines are used to generate an unique chip select signal. This
address technique is normally used in large memory systems.
Linear Decoding:
In small system hardware for the decoding logic can be eliminated by using only required number of
addressing lines (not all). Other lines are simple ignored. This technique is referred as linear decoding or
partial decoding. Control signals BHE and Ao are used to enable odd and even memory banks,
respectively. Figure shows the addressing of 16K RAM (6264) with linear decoding. The address line
A19 is used to select the RAM chips. When A19 is low, chip is selected, otherwise it is disabled. The
status of A14 to A18 does not affect the chip selection logic. This gives you multiple addresses (shadow
addresses). This technique reduces the cost of decoding circuit, but it gas drawback of multiple
addresses
Fig 3.5 Linear decoding
Block Decoding:
In a microcomputer system the memory array is often consists of several blocks of memory chips. Each
block of memory requires decoding circuit. To avoid separate decoding for each memory block special
decoder IC is used to generate chip select signal for each block.
Input Port
The input device is connected to the microprocessor through buffer. The simplest form of a input port is
a buffer as shown in the figure. This buffer is a tri-state buffer and its output is available only when
enable signal is active. When microprocessor wants to read data from the input device (keyboard), the
control signals from the microprocessor activates the buffer by asserting enable input of the buffer. Once
the buffer is enabled, data from the device is available on the data bus. Microprocessor reads this data by
initiating read command.
Output Port
It is used to send the data to the output device such as display from the microprocessor. The simplest
form of the output port is a latch.
The output device is connected to the microprocessor through latch as shown in the figure. When
microprocessor wants to send data to the output device it puts the data on the data busand activates the
clock signal of the latch, latching the data from the data bus at the output of latch. It is then available at
the output of latch for the output device.
o Some of the peripheral devices developed by Intel for 8085/8086/8088 based system are:
o The microprocessor can communicate with external world or other systems using two
types of communication interfaces. They are:
• Parallel Communication Interface
• Serial Communication Interface
The 8255 chip is also called as Programmable Peripheral Interface/Programmable Input Output.
The Intel’s 8255 is designed for use with Intel’s 8-bit, 16-bit and higher capability microprocessors
The 8255 is a 40 pin integrated circuit (IC), designed to perform a variety of interface functions in a
computer environment.
It is flexible and economical.
8255A Pin Diagram / 8255A Signals
8255 has 24 input/output lines which may be individually programmed.
2 groups of I/O pins are named as
• Group A (Port-A & Port C Upper)
• Group B (Port-B & Port C Lower)
3 ports(each port has 8 bit)
• Port A lines are identified by symbols PA0-PA7
• Port B lines are identified by symbols PB0-PB7
• Port C lines are identified by PC4-PC7 , PC3-PC0
D0 -D7 - Data input/output lines for the device. All information read from and written
to the 8255 occur via these 8 data lines.
CS (Chip Select) - If this line is a logic 0, the microprocessor can read and write to the 8255.
RESET - The 8255 is placed into its reset state if this input line is logic 1.
RD - This is the input line driven by the microprocessor and should be low to indicate read
operation to 8255.
WR - This is an input line driven by the microprocessor. A low on this line indicates write
operation.
A1-A0 - These are the address input lines and are driven by the microprocessor.
VCC – Power Supply
GND – Ground Reference.
EXAMPLE 1:
EXAMPLE 2:
3. SERIAL COMMUNICATION INTERFACE (8251)
o Programmable chip designed for synchronous and asynchronous serial data transmission
o 28 pin DIP
o Converts the parallel data into a serial stream of bits suitable for serial transmission.
o Receives a serial stream of bits and convert it into parallel data bytes to be read
by a microprocessor
o Receiver Signals :
RxD (Receiver data) : This input receives a composite serial stream of data
on the rising edge of RxC.
RxRDY (Receiver Ready) : This output indicates that the 8251 Pin
Diagram contains a character that is ready to be input to the CPU.
RxC (Receiver Clock) :This clock input controls the rate at which
the character is to be received.
o SYNDET (Sync Detect)/ BRKDET (Break Detect): This pin is used in synchronous
mode for detection of synchronous characters and may be used as either input or
output.
Transmitter :
o Accepts parallel data and converts it into serial data
o Two registers
o Buffer Register - To hold eight bits
o Output Register - Converts eight bits into a stream of serial bits
o Transmits data on TxD pin with appropriate framing bits(Start and Stop)
o Signals associated with Transmitter section :
o TxD – Transmit Data
– Serial bits are transmitted on this line
o TxC – Transmitter Clock
– Controls the rate at which bits are transmitted
o TxRDY – Transmitter Ready
– Can be used either to interrupt the MPU or indicate the status
o TxE – Transmitter Empty
– Logic 1 on this line indicate that the output register is empty
Receiver :
o Accepts serial data from peripheral and converts it into parallel data
o The section has two registers :
o Input Register
o Buffer Register
o Signals associated with Receiver Section :
o RxD – Receive Data
- Bits are received serially on this line and converted into parallel
bytein the receiver input
o RxC – Receiver Clock
o RxRDY – Receiver Ready
- It goes high when the USART has a character in the buffer
register and is ready to transfer it to the MPU.
Modem Controller :
o Used to establish data communication modems over telephone line
o Signals associated with Modem Controller Section :
– DSR (Data Set Ready): This input signal is used to test modem conditions such
as Data Set Ready.
– DTR (Data Terminal Ready): This output signal is used to tell modem that
Data Terminal is ready.
– RTS (Request to Send): This output signal is asserted to begin transmission.
– CTS (Clear to Send) : A low on this input enables the 8251A to transmit serial
data if the TxE bit in the command byte is set to a “one”.
When a data character is sent to 8251A by the CPU, it adds start bits prior to the serial data bits, followed
by optional parity bit and stop bits using the asynchronous mode instruction control word format. This
sequence is then transmitted using TXD output pin on the falling edge of TXC.
Asynchronous Mode (Receive)
A falling edge on RXD input line marks a start bit. The receiver requires only one stop bit to mark end of
the data bit string, regardless of the stop bit programmed at the transmitting end. The 8-bit character is then
loaded into the into parallel I/O buffer of 8251.
RXRDY pin is raised high to indicate to the CPU that a character is ready for it. If the previous character
has not been read by the CPU, the new character replaces it, and the overrun flag is set indicating that the
previous character is lost.
The control words of Block Diagram of 8251 Microcontroller are split into two formats.
Mode instruction (Setting of Function)
Command instruction (Setting of Operation)
8251 Mode Register – Asynchronous Mode Format
The TXD output is high until the CPU sends a character to 8251 which usually is a SYNC character. When
CTS line goes low, the first character is serially transmitted out. Characters are shifted out on the falling
edge of TXC .Data is shifted out at the same rate as TXC , over TXD output line. If the CPU buffer
becomes empty, the SYNC character or characters are inserted in the data stream over TXD output.
In this mode, the character synchronization can be achieved internally or externally. The data on RXD pin
is sampled on rising edge of the RXC. The content of the receiver buffer is compared with the first SYNC
character at every edge until it matches. If 8251 is programmed for two SYNC characters, the subsequent
received character is also checked. When the characters match, the hunting stops. The SYNDET pin set
high and is reset automatically by a status read operation. In the external SYNC mode, the synchronization
is achieved by applying a high level on the SYNDET input pin that forces 8251 out of HUNT mode. The
high level can be removed after one RXC cycle. The parity and overrun error both are checked in the same
way as in asynchronous mode.
8251 Mode Register – Synchronous Mode Format
The 8259 is known as the Programmable Interrupt Controller (PIC) microprocessor. In 8085 and
8086 there are five hardware interrupts and two hardware interrupts respectively. By adding 8259,
we can increase the interrupt handling capability. This chip combines the multi-interrupt input
source to single interrupt output. This provides 8-interrupts from IR0 to IR7.
Vcc and Gnd It is the Power supply and ground pins. +5V power supply is used in this chip.
D7-D0 For communication with the processor, there are Eight bi-directional data pins.
RD’ It is an active low control input line. It is used to read contents of the internal registers. It is
connected to IOR’ or MEMR’ of the system bus.
WR’ It is an active low-input pin which is activated by the processor to write the control information to
8259. It is connected to IOWR’ or MEMW’ of the system bus.
CS’ For selecting the chip it is used an active low input pin.
A0 An address input pin used along with RD* and WR* which is used to identify the various command
PIN Name Description and Purposes
words. It is connected to one of the address lines of the system address bus.
IR0-IR7 There are Eight asynchronous interrupt request inputs. These signals are generated by peripherals.
These interrupt requests can be programmed for level-trigger or edge-triggered mode.
INT A strong active high-output pin which interrupts the processor. Always connected to the INTR
interrupt input of 8085. The INT output is only activated when the interrupt request is valid.
INTA’ It is termed as an active low-input pin. The 8259 receives the signal from INTA* to the output of
8086. 8086 sends the two consecutive INTA* signals, the 8259 sends a 3-byte CALL instruction to
the 8086 via D7-0 pins. The two bytes termed as second and third bytes of the CALL instruction
contains the ISS address which depends on the IR input of 8259 that is going to be serviced.
CAS:2-0 These are bi-directional 3-bit cascaded lines. Used only when there are multiple 8259s in the
system. The interrupt control system might have a master 8259 and maximum eight Slave 8259s.
In master mode, these lines function as output lines. In this mode, the PIC places a 3-bit slave
identification number on cascade lines.
SP’ /EN’ SP’/EN’ stands for “slave program/enable buffer”. This pin serves dual function. In non buffered
mode, it functions as SP’ input line. SP’ is used to distinguish between master and slave PICs. In
buffered mode it functions as an EN’ output line. In this mode, it is used to enable data buffers.
Block Diagram of 8259
Block Description
Data Bus Buffer This block is used to communicate between 8259 and 8085/8086 by acting
as buffer. It takes the control word from 8085/8086 and send it to the 8259.
After selection of Interrupt by 8259 (based on priority of the interrupt), it
transfers the opcode of the selected interrupts and address of ISR to the
other connected microprocessor. It can send maximum 8-bit at a time.
R/W Control Logic This block works when the value of pin CS is 0. This block is used to flow
Block Description
the data depending upon the inputs of RD and WR. These are active low
pins for read and write.
Control Logic It controls the functionality of each block. It has pin INTR which is
connected with other microprocessors for taking the interrupt request. The
INT pin is used to give the output. If 8259 is enabled, and also the interrupt
flags of other microprocessors are high then this causes the value of the
output INT pin high, and in this way 8259 responds to the requests made
by other microprocessors.
Interrupt Request This unit stores the interrupt requests generated by the peripheral devices
Register that are requesting the service from the processor.
Interrupt Service This register unit stores the interrupts which are currently being executed
Register by the processor.
Priority Resolver This logic unit decides that among all the interrupt request present in the
IRR which holds the highest priority and needs to be executed first.
Cascade Buffer To increase the Interrupt handling capability, we can cascade more number
of pins, by using cascade buffer. When we are going to increase the
interrupt capability, CAS lines are used to control multiple interrupts.
It permits the operation of the system in two modes: master
mode and slave mode.
In the master mode of operation, it acts as a cascaded buffer. Whereas in
slave mode, this unit acts as a comparator.
Programming 8259A (Command Words of 8259)
The 8259 Programmable Interrupt Controller requires two types of command words.
Initialization Command Words (ICWs) and
Operational Command Words (OCWs).
A write command issued to the 8259 with A0 = 0 and D4 = 1 is interpreted as ICW1, which starts the initialization
sequence. It specifies,
A write command following ICW1, with A0 = 1 is interpreted as ICW2. This is used to load the high order byte of
the interrupt vector address of all the interrupts.
ICW3 command word is used when there is more than one 8259 present in the system i.e. when SNGL bit in
ICW1 is 0, then it will load 8-bit slave register.
It is loaded only, if the D0 bit of ICW1 is seta The format of ICW4 is shown in Fig. 14.79.
It specifies,
Whether to use special fully nested mode or non special fully nested mode.
Whether to use buffered mode or non buffered mode.
Whether to use Automatic EOI or Normal EOI.
CPU used, 8086/8088 or 8085.
Operation Command Word 1 (OCW 1):
It is used to set and reset the mask bits in IMR(interrupt mask register). M7 – M0 describes 8 mask bits
A Write command with A0 = 1 and D4 D3 = 00 is interpreted as OCW2. The R (Rotate), SL (Select-Level), EOI
bits control the Rotate and End Of Interrupt Modes and combinations of the two. L 2-L0 are used to specify the
interrupt level to be acted upon when the SL bit is active.
Operation Command Word 3 (OCW3):
OCW3 is used to read the status of the registers; and to set or reset the Special Mask and Polled modes.
8259 Status Read Operations:
The status of the Interrupt Request Register, the Interrupt-Service Register, and the Interrupt Mask Regiter of the
8259 may be read by issuing appropriate Read commands as described further.
An OCW3 with RR (Read Register) = 1 and RIS (Read ISR) = 0 set up the 8259 for a status read of the Interrupt
Request Register.
When the 8259 is not in the Polled mode, after it is set up for. an IRR status read operation, all Read commands
with A0=1 cause the 8259 to send the IRR status word.
An OCW3 with RR = 1 and ISR = 1 sets up the 8259 for a status read of the Interrupt-Service Register. A
subsequent read command issued to the 8259 will cause the 8259 to send the contents of the ISR onto the data
bus.
A Read command issued to the 8259 Programmable Interrupt Controller with A0 = 1 (with RD, CS = 0 ) causes
the 8259 to put the contents of the Interrupt Mask Register on the data bus. OCW3 is not required for a status read
of the IMR.
5. Poll mode :
In this mode the INT output is not used. The microprocessor checks the status of interrupt requests by issuing poll
command. The microprocessor reads contents of 8259A after issuing poll command. During this read operation
the 8259A provides polled word and sets ISR bit of highest priority active interrupt request FORMAT.
It is designed by Intel to transfer data at the fastest rate. It allows the device to transfer the data directly
to/from memory without any interference of the CPU. Using a DMA controller, the device requests the CPU
to hold its data, address and control bus, so the device is free to transfer data directly to/from the memory.
The DMA data transfer is initiated only after receiving HLDA signal from the CPU.
FEATURES OF 8257
It has four channels that can be used over four I/O devices.
Each channel has 16-bit address and 14-bit counter.
Each channel can transfer data up to 64 KB.
Each channel can be programmed independently.
Each channel can perform read transfer, write transfer and verify transfer operations.
It operates in 2 modes, i.e., Master mode and Slave mode.
The pin configuration of DMA Controller (8257) is shown in Figure 3and the descriptions are as follows:
DRQ0−DRQ3
These are the four individual channel DMA request inputs, which are used by the peripheral devices for
using DMA services. When the fixed priority mode is selected, then DRQ0 has the highest priority and DRQ3
has the lowest priority.
DACK0 − DACK3
These are the active-low DMA acknowledge lines, which updates the requesting peripheral about the
status of their request by the CPU. These lines can also act as strobe lines for the requesting devices.
D0 − D7
These are bidirectional, data lines which are used to interface the system bus with the internal data bus
of DMA controller. In the Slave mode, it carries command words to 8257 and status word from 8257. In the
master mode, these lines are used to send higher byte of the generated address to the latch. This address is
further latched using ADSTB signal.
IOR
It is an active-low bidirectional tri-state input line, which is used by the CPU to read internal registers of
8257 in the Slave mode. In the master mode, it is used to read data from the peripheral devices during a
memory write cycle.
IOW
It is an active low bi-direction tri-state line, which is used to load the contents of the data bus to the 8-bit
mode register or upper/lower byte of a 16-bit DMA address register or terminal count register. In the master
mode, it is used to load the data to the peripheral devices during DMA memory read cycle.
CLK
It is a clock frequency signal which is required for the internal operation of 8257.
RESET
This signal is used to RESET the DMA controller by disabling all the DMA channels.
A0 - A3
These are the four least significant address lines. In the slave mode, they act as an input, which selects
one of the registers to be read or written. In the master mode, they are the four least significant memory address
output lines generated by8257.
CS
It is an active-low chip select line. In the Slave mode, it enables the read/write operations to/from
8257. In the master mode, it disables the read/write operations to/from 8257.
READY
It is an active-high asynchronous input signal, which makes DMA ready by inserting wait states.
HRQ
This signal is used to receive the hold request signal from the output device. In the slave mode, it is
connected with a DRQ input line 8257. In Master mode, it is connected with HOLD input of the CPU.
HLDA
It is the hold acknowledgement signal which indicates the DMA controller that the bus has been granted
to the requesting peripheral by the CPU when it is set to1.
MEMR
It is the low memory read signal, which is used to read the data from the addressed memory locations
during DMA read cycles.
MEMW
It is the active-low three state signal which is used to write the data to the addressed memory location
during DMA write operation.
ADSTB
It is a control output line used to split data and address line through latches.
AEN
This signal is used to disable the address bus/data bus.
TC
It stands for ‘Terminal Count’, which indicates the present DMA cycle to the present peripheral
devices.
MARK
The mark will be activated after each 128 cycles or integral multiples of it from the beginning. It
indicates thecurrent DMA cycle is the 128th cycle since the previous MARK output to the selected
peripheral device.
Vcc
It is the power signal which is required for the operation of the circuit.
The functional Block Diagram of DMA controller(8257) is shown in Figure and the description are as follows:
Itconsists of five functional blocks:
1. Data bus buffer
2. Control logic
3. Read/write logic
4. Priority Resolver
5. DMA channels
Read/Write Logic:
In the slave mode, the read/write logic accepts the I/O Read or I/O Write signals, decodes the Ao-A3 lines
and either writes the contents of the data bus to the addressed internal register or reads the selected register
dependingupon whether IOW or IOR signal is activated. In master mode, the read/write logic generates the IOR and
IOW signals to control the dataflow to or from the selected peripheral.
Control Logic:
The control logic controls the sequences of operations and generates the required control signals like AEN,
ADSTB, MEMR,MEMW, TC and MARK along with the address lines A4-A7, in master mode.
Priority Resolver:
The priority resolver resolves the priority of the four DMA channels depending upon whether normal
priority or rotating priority is programmed.
DMA CHANNELS / Register Organization of 8257:
The 8257 performs DMA operation over four independent DMA channels with thefollowing Registers.
6. APPLICATIONS OF 8255 – TRAFFIC LIGHT CONTROLLER
Traffic light controller interface module is designed to simulate the function of four way traffic light
controller.
Combinations of red, amber and green LEDs are provided to indicate Halt, Wait and Go signals for
vehicles.
Combination of red and green LEDs are provided for pedestrian crossing.
36 LEDs are arranged in the form of an intersection.
A typical junction is represented in the Figure.
Each road is named North (N), South (S), East (E) and West ( W).
LED ARRANGEMENTS
At the left corner of each road, a group of five LEDs (Red, Amber and 3 Green) are arranged in the
form of a T-section to control the traffic of that road.
LED’s L1, L10, L19 & L28 (Red) are for the stop signal for the vehicles on the road N, S, W, & E
respectively.
L2, L11, L20 & L29 (Amber) indicates wait state for vehicles on the Road N, S, W, & E
respectively.
L3, L4 & L5 (Green) are for left, strait and right turn for the vehicles on road S.
Similarly, L12-L13-L14(Green), L23-L22-L21(Green) & L32-L31-L30(Green) simulates same
function for the roads E, N, W respectively.
A total of 16 LED’s (2 Red & 2 Green at each road) are provided for pedestrian crossing.
L7-L9. L16-L18, L25-L27 & L34-L36 (Green) when ON allows pedestrians to cross.
L6- L8, L15-L17, L24-L26 & L33-L35 (Red) when ON alarms the pedestrians to wait.
To minimize the hardware pedestrian’s indicator LEDs (both red and green are connected to
same port lines (PC4 to PC7) with red inverted.
Red LEDs L10 & L28 are connected to port lines PC2 & PC3 while L1 & L19are connected to
lines PC0 & PC1 after inversion. All other LED’s (amber andgreen) are connected to port A & B.
WORKING
8255 is interfaced with 8086 in I/O mapped I/O and all ports are output ports.
The working assumes no entry of vehicles from North to West, from road East to South.
At the beginning , all red LEDs are switched ON, and all other LEDsare switched OFF.
Amber LED is switched ON before switching over to proceed state from Halt state.
The sequence of traffic followed is given below.
From road north to East, from road east to north, from road south to west from roadwest to south, from
road west to north.
From road north to East, from road south to west, from road south to north, fromroad south to east,
from road north to south, from road south to north.
Pedestrian crossing at roads west & east.
From road east to west, from road west to east, pedestrian crossing at roads north& south.
o Typical uses of LEDs include alarm devices, timers and confirmation of user input such
as a mouse click or keystroke.
Seven-Segment displays
o 7 segment displays are generally used as numerical indicators and consists of a number
of LEDs arranged in seven segments.
o Any number between 0 to 9 can be indicated by lighting the appropriate segments.
o The seven segments are labeled a to g and dot is labeled as h.
o By forward biasing different LED segments, we can display the digits 0 through 9.
o LED indicators are of two type’s namely - common anode type and common cathode type.
o In a common anode type all the anodes are connected together.
o In a common cathode type all the cathodes are connected together
o Anode is connected through a resistor to GND & the Cathode is connected to the
Microprocessor pin.
o When the Port Pin is HIGH the LED is OFF & when the Port Pin LOW, the LED is turned ON.
Common Anode Type Common Cathode Type
Interfacing LED
o We now want to flash a LED.
o It works by turning ON a LED & then turning it OFF & then looping back to START.
o A delay is generated between the flashing of LEDs.
o For common anode, when anode is connected to positive supply, a low voltage is applied
to a cathode to turn it on.
o Here BCD to seven segment decoder, IC7447 is used to apply low voltages at cathodes
according to BCD input applied to 7447.
o To limit the current through LED segments resistors are connected in series with the segments.