Ppi 8255
Ppi 8255
Ppi 8255
D7 D6 D5 D4 D3 D2 D1 D0
Group A Group B
Port C Upper
1=Input Port C Lower
Mode set
0=Output 1=Input
1: i/o MODE
0: BSR mode Port A 0=Output
1=Input Port B
0=Output 1=Input
Mode selection 0=Output
00=mode 0 Mode selection
01=mode 1 0=mode 0
1x=mode 2 1=mode 1
operation modes: i) I/O modes (M0,M1,&M2)
ii) BSR (Bit set/Reset) mode
When i/p device has data to send it checks if IBF (input buffer full)
signal is 0.
If 0, it sends data on PA/PB7-0 and activates STB* (Strobe) signal.
(STB* is active low. )
When STB* goes high, the data enters the port and IBF gets
activated.
If the Port interrupt is enabled, INT is activated. This interrupts the
processor.
Processor reads the port during the ISS. Then IBF and INT get 11
deactivated.
82C55: Mode 1 Strobed Input
X X X BIT SET/RESET
1=SET
Don’t care 0=RESET
4 5 6 7 0 1 2 3
(LP) (HP)
AUTOMATIC ROTATION MODE:
• In this mode, a device after being serviced, receives
the lowest priority.
• Assuming that the IR2 has just been serviced, it will
receive the 7th priority
• Non Specific EOI: When this command send to the 8259 PIC,
it resets the highest priority ISR bit.
• Specific EOI: This command specifies which ISR bit to reset
p
8253/8254 Programmable counter / timer
• When the counter is read, the data within the counter will
not be disturbed.
A1 A0 Operation
0 0 Counter 0
0 1 Counter 1
1 0 Counter 2
1 1 Control word register
Counter operation
To operate a counter, a desired 16-bit count is loaded in its
register and, on command, it begins to decrement the count until
it reaches 0. At the end of the count, it generates a pulse that can
be used to interrupt the CPU.
Like other modes, counting process will start the next clock cycle after COUNT
is sent. OUT will then remain high until the counter reaches 1, and will go low
for one clock pulse. OUT will then go high again, and the whole process
repeats itself.
8237DMA CONTROLLER
Introduction:
Direct memory access (DMA) is a method that allows an
input/output (I/O) device to send or receive data directly to
or from the main memory, bypassing the CPU to speed up
memory operations. The process is managed by a chip known
as a DMA controller(DMAC).
Basic DMA Operation:
Two control signals are used to request and acknowledge a
direct memory access (DMA) transfer in the microprocessor-
based system.
The HOLD signal as an input(to the processor) is used to
request a DMA action.
The HLDA signal as an output that acknowledges the DMA
action.
When the processor recognizes the hold, it stops its execution and
enters hold cycles.
HLDA becomes active to indicate that the processor has placed its
buses at high-impedance state.
Basic DMA Definitions:
Direct memory accesses normally occur between an I/O
device and memory without the use of the microprocessor.
A DMA read transfers data from the memory
to the I/O device.
A DMA write transfers data from an I/O device
to memory.
The system contains separate memory and I/O control
signals. Hence the Memory & the I/O are controlled
simultaneously
The DMA controller provides memory with its address, and
the controller signal selects the I/O device during the
transfer.
Data transfer speed is determined by speed of the memory
device or a DMA controller.
The 8237 DMA Controller
8237 is a four-channel device compatible with
8086/8088, adequate for small systems.
Each channel is capable of addressing a full
64K-byte section of memory.
Expandable to any number of DMA channel inputs
8237 is capable of DMA transfers at rates up to 1.6MB
per second.
:
CPU having the control over the bus When DMA operates:
Programmable DMA controller. (a) Block diagram and (b) pin-out.
7
8237 Internal Registers
CAR
The current address register holds a 16-bit memory
address used for the DMA transfer.
Each channel has its own current address register for this
purpose.
When a byte of data is transferred during a DMA operation,
CAR is either incremented or decremented depending on
how it is programmed.
CWCR
The current word count register programs a channel for
the number of bytes to transferred during a DMA action.
CR
The command register programs the operation of the
8237 DMA controller.
The register uses bit position 0 to select the memory-to-
memory DMA transfer mode.
Memory-to-memory DMA transfers use DMA channel 0 to
hold the source address
DMA channel 1 holds the destination address
command register.
12
BA and BWC
The base address (BA) and base word count (BWC)
registers are used when auto-initialization is selected for a
channel.
In auto-initialization mode, these registers are used to reload
the CAR and CWCR after the DMA action is completed.
MR
The mode register
programs the mode of
operation for a channel.
Each channel has its own
mode register as selected by
bit positions 1 and 0.
Remaining bits of the mode
register select operation,
auto-initialization,
increment/decrement, and
mode for the channel
14
BR
The bus request register is used to request
a DMA transfer via software.
very useful in memory-to-memory transfers, where an external signal is
not available to begin the DMA transfer
15
MRSR
The mask register set/reset sets or clears the channel mask.
if the mask is set, the channel is disabled
the RESET signal sets all channel masks
to disable them
16
MSR
The mask register clears or sets all of
the masks with one command instead of individual channels, as with
the MRSR.
17
SR
The status register shows status
of each DMA channel. The TC bits
indicate if the channel has reached
its terminal count (transferred all
its bytes).
When the terminal count is
reached, the DMA transfer is
terminated for most modes
of operation.
The request bits indicate whether
the DREQ input for a given channel
is active.
18
Master clear
Acts exactly the same as the RESET signal to the 8237.
As with the RESET signal, this command disables all channels
Clear mask register
Enables all four DMA channels.
Clear the first/last flip-flop
Clears the first/last (F/L) flip-flop within 8237.
The F/L flip-flop selects which byte (low or high order) is
read/written in the current address and current count registers.
if F/L = 0, the low-order byte is selected
if F/L = 1, the high-order byte is selected
Any read or write to the address or count register automatically
toggles the F/L flip-flop.
Memory-to-memory transfer is much more powerful
than the automatically repeated MOVSB instruction.
most modern chip sets do not support the memory-to-
memory feature
8237 requires only 2.0 µs per byte, which is over twice as
fast the existing data transfer.
20
8251 USART (Universal
Synchronous Asynchronous
Receiver Transmitter)
The 8251 is a USART (Universal Synchronous Asynchronous
Receiver Transmitter) for serial data communication. As a
peripheral device of a microcomputer system, the 8251
receives parallel data from the CPU and transmits serial data
after conversion. This device also receives serial data from
the outside and transmits parallel data to the CPU after
conversion.
Serial data transmission is
classified as
• Simplex: the data are transmitted in only
one direction. Ex. Transmission from
computer to printer
• Half Duplex: Data are transmitted in both
direction but not simultaneously. Ex .
Walky talky
• Full Duplex: Data are transmitted in both
direction simultaneously. ex. Telephone
Syn and asycn transmission
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.
The clock signal, TxC (low) controls the rate at which the bits are transmitted
by the USART.
• RxC: controls the rate at which bits are received by USART. In asych
mode, it can be 1, 16 or 64 times the baud.
• RxRDY : When the input register loads a parallel data to buffer register, the
RxRDY line goes high. RxRDY Can be used either to indicate the status or
to interrupt MPU.
• 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.
•
Control logic and registers
1) Mode Instruction
Mode instruction is used for setting the function of the 8251. Items set by mode
instruction are as follows:
• Synchronous/asynchronous mode
• Stop bit length (asynchronous mode)
• Character length
• Parity bit
• Baud rate factor (asynchronous mode)
The bit configuration of mode instruction is shown in Figures 2 and 3. In the case of
synchronous mode, it is necessary to write one-or two byte sync characters. If sync
characters were written, a function will be set because the writing of sync characters
constitutes part of mode instruction.
2) Command
Command is used for setting the operation of the 8251. It is possible to
write a command whenever necessary after writing a mode instruction
and sync characters.
Items to be set by command are as follows:
• Transmit Enable/Disable
• Receive Enable/Disable
• DTR, RTS Output of data.
• Resetting of error flag.
• Sending to break characters
• Internal resetting
• Hunt mode (synchronous mode)
Pin description of 8251
D 0 to D 7 (l/O terminal)
This is bidirectional data bus which receive control words and transmits data
from the CPU and sends status words and received data to CPU.
RESET (Input terminal)
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.
CLK (Input terminal)
CLK signal is used to generate internal device timing.
CLK signal is independent of RXC or TXC.
However, the frequency of CLK must be greater than 30 times the RXC and
TXC at Synchronous mode and Asynchronous "x1" mode, and must be greater
than 5 times at Asynchronous "x16" and "x64" mode.
WR (Input terminal)
This is the "active low" input terminal which receives a signal for writing
transmit data and control words from the CPU into the 8251.
RD (Input terminal)
This is the "active low" input terminal which receives a signal for reading
receive data and status words from the 8251.
C/D (Input terminal)
This is an input terminal which receives a signal for selecting data or command
words and status words when the 8251 is accessed by the CPU.
If C/D = low, data will be accessed. If C/D = high, command word or status word
will be accessed.
CS (Input terminal)
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.
TXD (output terminal)
This is an output terminal for transmitting data from which serial-converted data is
sent out. The device is in "mark status" (high level) after resetting or during a status
when transmit is disabled. It is also possible to set the device in "break status" (low
level) by a command.
TXRDY (output terminal)
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 (Output terminal)
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)
The active low signals RD, WR, CS and C/D(Low) are used for read/write
operations with these three registers.
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.
Interfacing RS232 terminal using 8251A
Tr rdy
Initialization intruction:
SETUP: MVI A, CAh ; load mode word
OUT FFh ; write mode word to control rgstr
MVI A, 11h ; load command word
OUT FFh ; enable trnsmitter
STATUS: IN FFh ; read stats word
ANI 01h ; mask all bits except D0
JZ STATUS ; if D0 = 0, Tr buffer is full, go back and wait
rcv
transmit
Rd o/p port
Init bit cntr N
Strt bit?
Snd strt bit
Y
Wait ½ bit time
Wait bit time
N
Bit still low?
Get chr into A
Y
Set bit cntr
o/p bit using D0 Clr data rgstr
Wait bit time
Wait bit time
Rd i/p
Save bit
Rotate nxt bit to D0.
Dcr bit cntr Redy to rcv nxt bit
Dcr bit cntr
N
Last bit? N
Last bit?
Y
Add parity Chk parity
Snd stop bits Wait for stop bits
return return
IIE - SAP
A set of eight
A set of four output lines for
scan lines interfacing
and eight display.
return lines Scan line are
The keyboard for used to drive
display interfacing multiplexed 7
controller keyboard segment display
chip 8279
provides IIE - SAP
WHY 8279???
8255 can be used in interfacing keyboards and displays.
The disadvantages of this method of interfacing keyboard
and display is that the processor has to refresh the display
and check the status of the keyboard periodically using
polling technique.
BLOCK SCAN
MPU
DIA i) Encoded
INTERFACE
8279 ii) Decoded
When a key is pressed, a debounce logic comes into operation. After the
debounce period (i.e. wait for 10 ms). , if the key continues to be detected,
The code of key is directly transferred to the sensor RAM along with SHIFT
and CONTROL key status.
2 key lock out: If two keys are pressed simultaneously within a debounce
cycle, no key is recognized and no key code is stored in FIFO RAM till one of
them remains closed and the other is released.
N – key roll over
Any number of keys can be pressed simultaneously and recognized in the
order, the keyboard scan recorded them. All the codes of such keys are
entered into FIFO.
IIE - SAP
In this mode, the first pressed key need not be released before the second is
• CNTL/STB i/p mode:, control lines that enters data in FIFO
RAM . Shift: The status of shift is stored along with key code in
FIFO RAM .
• In Scanned Sensor Matrix mode, a sensor array can be
interfaced with 8279 using either encoded or decoded scans
to scan the key matrix and refresh the display.
IIE - SAP
Output (Display) Modes : 8279 provides two
output modes for selecting the display options.
a) Keyboard Display Mode Set : The format of the command word to select
different modes of operation of 8279 is given below with its bit definitions.
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 D D K K K
IIE - SAP
SENSOR MATRIX
SENSOR MATRIX
IIE - SAP
B) Programmable clock :
The clock for operation of 8279 is obtained by dividing
the external clock input signal by a programmable
constant called pre scaler.
D7 D6 D5 D4 D3 D2 D1 D0
0 0 1 P P P P P
IIE - SAP
c) Read FIFO / Sensor RAM : The format of this command is
given below.
D7 D6 D5 D4 D3 D2 D1 D0
0 1 0 AI X A A A
This word is written to set up 8279 for reading FIFO/ sensor RAM.
In scanned keyboard mode, AI and AAA bits are of no use. The 8279
will automatically drive data bus for each subsequent read, in the
same sequence, in which the data was entered.
In sensor matrix mode, the bits AAA select one of the 8 rows of
RAM.
If AI flag is set, each successive read will be from the subsequent
RAM location. IIE - SAP
d) Read Display RAM :
This command enables a programmer to read the display RAM data.
D7 D6 D5 D4 D3 D2 D1 D0
0 1 1 AI A A A A
IIE - SAP
d) Write Display RAM :
This command enables a programmer to write the display RAM data.
D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 AI A A A A
CD: CLEAR DISPLAY ; CF: CLEAR FIFO RAM STATUS; CA: CLEAR ALL (both CD&CF)
IIE - SAP
h) End Interrupt / Error mode Set :
D7 D6 D5 D4 D3 D2 D1 D0
1 1 1 E X X X 1
E- Error mode
X- don’t care
For the sensor matrix mode, this command lowers the IRQ
line and enables further writing into the RAM.
Otherwise, if a change in sensor value is detected, IRQ
goes high that inhibits writing in the sensor RAM.
For N-Key roll over mode, if the E bit is programmed to be
‘1’, the 8279 operates in special Error mode
IIE - SAP
I/O Interface
IIE - SAP
IIE - SAP
ADC 0809
ADC 0809
• The ADC0809 is an 8-bit successive approximation type
ADC with inbuilt 8-channel multiplexer.
• The DAC will accept a digital (binary) input and convert to analog voltage
or current.
• Every DAC will have "n" input lines and an analog output.
• The smallest possible analog value that can be represented by the n-bit
binary code is called resolution.
• The resolution of DAC with n-bit binary input is 1/2nof reference analog
value.
DAC 0800
•
The DAC0800 is an 8-bit, high speed, current output DAC with a typical
settling time (conversion time) of 100 ns.
• The DAC0800 require a positive and a negative supply voltage in the range
of ± 5V to ±18V.
• It can be directly interfaced with TTL, CMOS, PMOS and other logic
families.
• For TTL input, the threshold pin should be tied to ground (VLC = 0V).
R-2R Ladder
pin configuration of DAC0800
DAC interfacing with 8085 thro 8255
DAC interfacing with 8051