Professional Documents
Culture Documents
75
BASIC MODES OF COMMUNICATION
Parallel communication implies sending a whole byte (or more) of data over multiple
parallel wires
Serial communication implies sending data bit by bit over a single wire
Transmitter Receiver
Full Duplex: Data are transmitted both
directions simultaneously
Receiver Transmitter
SERIAL COMMUNICATION: SYNCHRONOUS MODE
Synchronous
Communication
SERIAL COMMUNICATION: SYNCHRONOUS MODE
• In the synchronous mode, the transmitter and receiver share a common clock
• The transmitter typically provides the clock as a separate signal in addition to the
serial data
Clock
Transmitter Receiver
Data
The Transmitter
Shifts the data onto the serial line using its The Receiver
own clock Extracts the data using the clock
provided by the transmitter
Provides the clock as a separate signal
Converts the serial data back to the
parallel form
No start, stop, or parity bits added to data
SERIAL COMMUNICATION: ASYNCHRONOUS MODE
Asynchronous
Communication
SERIAL COMMUNICATION: ASYNCHRONOUS MODE
With asynchronous communication, the transmitter and receiver do not share a
common clock
Add: Start, Stop, Parity Bits Remove: Start, Stop, Parity Bits
Transmitter + – Receiver
Data
Shifts the parallel data onto the Extracts the data using its own clock
serial line using its own clock
Converts the serial data back to the
Also adds the start, stop and parallel form after stripping off the
parity check bits start, stop and parity bits
SERIAL COMMUNICATION: ASYNCHRONOUS MODE
Start Bit Bit time Sec Parity Bit 1 or 2 Stop Bits
Mark (Active low / 0) (Active high / 1)
D0 D1 D2 D3 D4 D5 D6 D7
1 Asynchronous Byte
Error Check
Parity: even or odd parity is indicated by transmitter and checked at
receiver’s end
Checksum: Sum of all data byte along with its 2’s complement –as last
byte sent by the transmitter and checked at receiver’s end
(result = 0 for no error)
SERIAL COMMUNICATION: ASYNCHRONOUS MODE
Error Check
Cyclic Redundancy:
SERIAL COMMUNICATION: ASYNCHRONOUS MODE
SERIAL COMMUNICATION: ASYNCHRONOUS MODE
SERIAL COMMUNICATION: ASYNCHRONOUS MODE
SERIAL COMMUNICATION: ASYNCHRONOUS MODE
SERIAL COMMUNICATION: ASYNCHRONOUS MODE
SERIAL COMMUNICATION: ASYNCHRONOUS MODE
Transmission Process:
1. Inform the receiver of the beginning and the end of the transmission and error
check
2. Convert a parallel word into stream of serial bits
3. Transmit one bit at a time with appropriate time delay, using one data line of an
output port. The time delay is determined by the speed of the transmission
Reception Process:
95
SOFTWARE SERIAL COMMUNICATION IN 8085
STARTSOD: MVI C, 0BH ;Set up counter C to count eleven bits
XRA A ; Reset carry to 0
NXTBIT: MVI A, 80H ;Set D to 1 in the accumulator
RAR ; Bring carry into D =0 for 1st time and set D to 1
SIM ;Output D =0 to mark the beginning of the frame
CALL BITTIME ; Wait up to bit-time s for bps baud rate
STC ;Set carry to 1 to ensure two stop bits
MOV A,B ;Place the ASCII character to be sent in ACC
RAR ;Place LSB of ASCII character in carry
MOV B,A ;Save the content for next transmit
DCR C ;One bit transmitted, decrease the counter
JNZ NXTBIT ;If all bits are not transmitted continue the loop
RET ;return to main program after transmission is complete 96
SOFTWARE SERIAL COMMUNICATION IN 8085
Sl.No Description Opcode Operand Byte M-Cycles T-States Hex Code Affected
Flags
58. Read Interrupt Mask RIM - 1 1 4 20 No Flag
97
SERIAL COMMUNICATION: ASYNCHRONOUS MODE
100
SERIAL INTERFACE CONTROLLER: 8251
Initialization of 8251
1. Mode Word: Baud rate, Stop bit, & Error Checking bit information
Control Register (16-bit)
2. Command Word: Enables data transmission and/or reception
3. Status word: Provides information of register status & transmission error Status Register (8-bit)
105
PROGRAMMING 8251 FOR ASYNCHRONOUS SERIAL COMMUNICATION
Mode Word:
Command Word:
EH IR RTS ER SBRK RxE DTR TxEN
Transmit Enable
1 = Enable
0 = Disable
• A program sequence which initializes the mode register and gives a command to enable the
transmitter and begin an asynchronous transmission of 7-bit characters followed by an even-parity
bit and 2 stop bits is:
MOV A, FAH
OUT FF H
MOV A, 33H
OUT FFH
110
PROGRAMMING 8251 FOR ASYNCHRONOUS SERIAL COMMUNICATION
Initialization Instructions
SET UP: MVI A, CAH ;Load the mode word
OUT FFH ;Write mode word in control register
MVI A,11H ;Load the command word to enable transmitter
OUT FFH ;Enable the transmitter
STATUS: IN FFH ;Read status register
ANI 01H ;Mask all bits except
JZ STATUS ;If = 0, the transmitter buffer is full; go back
;and wait
111
PROGRAMMING 8251 FOR ASYNCHRONOUS SERIAL COMMUNICATION
Transmission:
LXI SP, STACK JZ STATUS ;Is TxRDY 1?
LXI H, XX70H ;Memory pointer for message
; If not, wait
MOV C, M ;Set up register C as counter
INX H ;Point to next character
MVI A,00H ;Dummy mode word
MOV A,M ;Place character in the
OUT FFH ;Write dummy
accumulator
OUT FFH ; word in See
program
OUT FEH ;Send character to the
OUT FFH ; mode transmitter
description
; register
DCR C ;One character transmitted:
MVI A,40H ;Reset word ; decrement the counter
OUT FFH ;Reset 8251 JNZ STATUS ;If all characters are not yet
MVI A,CAH ;Initialize 8251 ;transmitted, go back and
OUT FFH ;transmit again
MVI A,11H HLT
OUT FFH
STATUS IN FFH 112
Reception:
113
SERIAL COMMUNICATION: LOGIC PROTOCOL
SERIAL COMMUNICATION: MAX232
SERIAL INTERFACE CONTROLLER: 8251
116
PROGRAMMABLE INTERRUPT CONTROLLER
117
PIN OUT & SIGNAL FLOW DIAGRAM
118
INTERRUPT SIGNALS
119
INTERRUPT PRIORITY, VECTOR ADDRESS, SENSITIVITY
NOTES:
1. The processor pushes the PC on the stack before branching to the indicated address.
2. The address branched to depends on the instruction provided to the CPU when the
120
interrupt is acknowledged.
INSTRUCTION SET: MACHINE CONTROL
Sl.No Description Opcode Operand Byte M-Cycles T-States Hex Code Affected Resart
Flags Add. (H)
54. PC points to an address location RST 0 1 3 12 C7 No Flag 0000
in page 0 of memory associated 1 CF 0008
to each of the 8 restart
instruction, after pushing its 2 D7 0010
current content –address of next 3 DF 0018
instruction –on stack. 4 E7 0020
5 EF 0028
6 F7 0030
7 FF 0038
55. Enables interrupts EI - 1 1 4 FB
56. Disables interrupt DI - 1 1 4 F3
121
INSTRUCTION SET: MACHINE CONTROL
122
INSTRUCTION SET: MACHINE CONTROL
123
PROGRAMMABLE INTERRUPT CONTROLLER: 8259A
Designed to work with 8080 A, 8085, 8086, 8088.
Handle eight interrupt inputs. This is equivalent to providing eight interrupt
pins on the processor in place of one INTR/INT pin.
Vector an interrupt request anywhere in the memory map. However, all the
eight interrupt are spaced at the interval of either four or eight location. This
eliminates the major drawback, 8085 interrupt, in which all interrupts are
vectored to memory location on page 00H.
Read the status of pending interrupts, in service interrupts, and masked interrupts.
Be set up to accept either the level triggered or edge triggered interrupt request.
125
PROGRAMMABLE INTERRUPT CONTROLLER: 8259A
126
PROGRAMMABLE INTERRUPT CONTROLLER: 8259A
127
PROGRAMMABLE INTERRUPT CONTROLLER: 8259A
128
PROGRAMMABLE INTERRUPT CONTROLLER: 8259A
129
8259A: INTERRUPT REGISTERS & PRIORITY RESOLVER
Interrupt request register (IRR)
The IRR is used to store all the interrupt levels which are requesting service
Priority Resolver
This logic block determines the priorities of the bits set in the IRR. The highest priority is
selected and strobbed into the corresponding bit of the ISR during INTA pulse
CPU-DEVICE COMMUNICATION MODE
131
Polling Mode Interrupt Driven Mode
8259A: MASTER AND SLAVE CONFIGURATION
• Master: The 8259A connected directly into the CPU (8085, 8086 etc.) INTR pin is
called as master
• Slave: The INT pin from the other 8259A connects into an IR input on the master.
This secondary or cascaded device is called as a slave
8259A: INTERFACE TO STANDARD SYSTEM BUS
8259A: CASCADED MODE
8259A: INTERRUPT SEQUENCE OF OPERATION
1. One or more of the INTERRUPT REQUEST lines (IR7–0) are raised high, setting the
corresponding Interrupt Request Register (IRR) bit(s).
2. The 8259A evaluates these requests –resolves priority, and sends an INT to the CPU, if
appropriate.
3. The CPU acknowledges the INT and responds with an INTA pulse.
4. Upon receiving an INTA from the CPU group, the highest priority In-Service Register (ISR)
bit is set, and the corresponding IRR bit is reset. The 8259A will also release a CALL
instruction code (11001101) onto the 8-bit Data Bus through its D7–0 pins.
8259A: INTERRUPT SEQUENCE OF OPERATION
5. This CALL instruction will initiate two more INTA pulses to be sent to the 8259A from the
CPU group.
6. These two INTA pulses allow the 8259A to release its pre-programmed subroutine address
onto the Data Bus. The lower 8-bit address is released at the first INTA pulse and the
higher 8-bit address is released at the second INTA pulse.
7. This completes the 3-byte CALL instruction released by the 8259A. In the Automatic End of
Interrupt (AEOI) mode the ISR bit is reset at the end of the third INTA pulse. Otherwise, the
ISR bit remains set until an appropriate EOI command is issued at the end of the
interrupt sequence. This option is determined by initialization command word (ICW)
8. The program counter points to the memory location specified by the CALL instruction
8259A: PROGRAMMING
ICW1 To initialize
A single or cascaded 8259s
Level trigger or edge triggered input
ICW4 is needed or not
8259A: INITIALIZATION
ICW2
Load the high order byte of the interrupt vector address of all
the interrupts
8259A: INITIALIZATION OF VECTOR ADDRESS
ICW3
Initialized only when cascaded 8259s are used
A single 8259 can connect to 8 slaves 8259s providing up
to 64 hardware interrupts
There are separate ICW3 words for the master and the
slave
8259A: INITIALIZATION
ICW4 Initialized for
80x86 or 8085
Auto or Normal EOI (End of
Interrupt)
Buffered or non buffered
Special or not special fully
nested mode
If
• Auto EOI: No need for an EOI
instruction used before RETI
in interrupt service routine
• Normal EOI: ICW2 must be
initialized
• Masked mode (cascaded): D4
must be 1
8259A: INTERRUPT MODES
An EOI command must be issued twice if in the Cascade mode, once for the master
and once for the corresponding slave.
• In Specific mode fully nested structure is preserved; specific IS bit for the peripheral
device to reset on EOI.
• In non-specific EOI mode the highest IS bit of those that are set, are automatically
reset; in the fully nested mode the highest IS level was necessarily the last level
acknowledged and serviced.
8259A: AUTOMATIC END OF INTERRUPT (EOI)
If AEOI = 1 in ICW4, then the 8259A will operate in AEOI mode continuously until
reprogrammed by ICW4.
In this mode the 8259A will automatically perform a non-specific EOI operation at the
trailing edge of the last interrupt acknowledge pulse (third pulse in MCS-80/85, second
in 8086).
This mode should be used only when a nested multilevel interrupt structure is not
required within a single 8259A.
The AEOI mode can only be used in a master 8259A and not a slave.
8259A: EXAMPLE
Four sources are connected to IR lines of 8259A: emergency signal, keyboard, A/D converter
and printer. Of these the emergency signal has the highest priority and printer has the lowest
priority. The vector address starts from 2060 and the space between consecutive ISR
location is 4. Interrupt is to be sensed by edge triggering. Activate automatic end of interrupt.
PROGRAMMABLE INTERVAL TIMER
151
PROGRAMMABLE INTERVAL TIMER: 8253 / 54
Generation of accurate time delay under software control
3 counters: counters 0, 1, 2
153
8253: COUNTER
155
8253: SYSTEM INTERFACE
156
8253: PROGRAMMING
Control word
157
8253: PROGRAMMING
Control word
158
8253: PROGRAMMING
Control word
159
8253: PROGRAMMING
160
8253: PROGRAMMING
161
8253: PROGRAMMING
162
8253: PROGRAMMING
163
8253: PROGRAMMING
164
8253: PROGRAMMING
165
8253: CLOCKING
166
8253: GATING
167
8253: PROGRAMMING
Control word
168
8253: ADDRESSING CONTROL & COUNT REGISTERS
169
8253: STATUS READING
170
8253: STATUS READING
171
8253: STATUS READING
172
8254: STATUS READING
Read back command
Status byte
173
8253: EXAMPLE 1
174
8253: EXAMPLE 1
175
8253: EXAMPLE 1
176
8253: EXAMPLE 2
177
8253: EXAMPLE 2
In mode 3 the relation between clock frequency to desired frequency
=
×
So, = = 2000 = 07 0 Control Word Format
HLT
8253: EXAMPLE 3
179
8253: EXAMPLE 3
To +5V
1Hz interrupt
2MHz Clock
180
8253: EXAMPLE 3
1
= = 2M = 50000 × 40
0.5 × 10
181
DIRECT MEMORY ACCESS
182
DMA OPERATION
• Direct memory access (DMA) is a process in which an external device takes over the
control of system bus from the CPU.
• DMA used for high-speed data transfer from/to mass storage peripherals, e.g.
CPU DMA
Data – Address - Control
Handshaking
MEMORY-TO-DEVICE DATA TRANSFER
TYPICAL DMA MODULE DIAGRAM
BASIC PROCESS OF DMA
In maximum mode:
Handshaking Pins: The HOLD and HLDA pins DMA request and acknowledge
Sequences:
2. CPU completes its current bus cycle and enters into a HOLD state
3. CPU grants the right of bus control by asserting a grant signal via the HLDA pin
5. Upon completion of the DMA operation, the peripheral asserts low to HOLD pin
again to relinquish bus control.
DMA CONTROLLER: 8237
8237 BLOCK DIAGRAM
8237 BLOCK DIAGRAM
8237A contain three basic block of control logic.
3. Internal registers: 8237 contain 344 bits of internal memory in the form
of register
8237 PIN DESCRIPTION
191
8237 PIN DESCRIPTION
192
8237 PIN DESCRIPTION
193
8237 PIN DESCRIPTION
194
8237 PIN DESCRIPTION
195
8237 INTERNAL REGISTERS SPECIFICATION
ADDRESSES
• This mode is used to cascade more than one 8237A together for simple system
expansion. The HRQ and HLDA signals from the additional 8237A are
connected to the DREQ and DACK signals of a channel of the initial 8237A.
DATA TRANSFER MODE
Cascade Transfer Mode
REQUEST REGISTER
The 8237A can respond to requests for DMA service which are initiated by software as well
as by a DREQ. Each channel has a request bit associated with it in the 4-bit Request
register. These are non-maskable and subject to prioritization by the Priority Encoder
network
MASK REGISTER
Each channel has associated with it a mask bit which can be set to disable the incoming
DREQ.
STATUS REGISTER
The Status register is available to be read out of the 8237A by the microprocessor. It
contains information about the status of the devices at this point.
OPERATION CODES
SOFTWARE COMMAND
Clear First/Last Flip-Flop: This command must be executed prior to writing or reading new
address or word count information to the 8237A. This initializes the flip-flop to a known state
so that subsequent accesses to register contents by the microprocessor will address upper
and lower bytes in the correct sequence.
Master Clear: This software instruction has the same effect as the hardware Reset. The
Command, Status, Request, Temporary, and Internal First/Last Flip-Flop registers are cleared
and the Mask register is set. The 8237A will enter the Idle cycle.
Clear Mask Register: This command clears the mask bits of all four channels, enabling them
to accept DMA requests.
ADDRESS CODE FOR SOFTWARE COMMAND
ADDRESS REGISTER COMMAND CODE
ADDRESS REGISTER COMMAND CODE
DMA CIRCUIT WITH 8085
PROGRAMMING FOR DMA