unit – ii interfacing

Upload: khadar-nawas

Post on 06-Apr-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 UNIT II Interfacing

    1/48

    UNIT II Interfacing

  • 8/3/2019 UNIT II Interfacing

    2/48

    Programmable Peripheral interface -8255

    Features:` Designed by Intel to interface with 8,16 bit & higher capability

    microprocessor with I/O peripherals

    ` It has 24 i/o lines which may be programmed in to two groups of

    12 lines or three groups of 8 lines` The two group i/o pins named as GROUP A and GROUP B

    ` Each group contains a two sub group of 8 bit i/o lines & 4 bit i/o

    lines

    ` Group A contains an 8 bit port A along with a 4 bit port C called

    Cupper

    ` Group B contains an 8 bit port B along with a bit port C called

    Clower

  • 8/3/2019 UNIT II Interfacing

    3/48

    8255 Pin diagram

    ` PA7-PA0 buffered/latched i/o 8 bit PORT A

    ` PB7-PB0 buffered/latched i/o 8 bit PORT B

    ` PC7-PC4 Upper nibble of PORT C

    ` PC3-PC0 Lower nibble of PORT C

    ` RD Read` WR-Write

    ` CS-Chip Select

    ` A0-A1 Address Lines

    ` D0-D7 Data Lines carries DATA or ControlWord to/from processor

    ` RESET Clears control word registers

  • 8/3/2019 UNIT II Interfacing

    4/48

    8255 internal Architecture

  • 8/3/2019 UNIT II Interfacing

    5/48

    ` Data Bus Buffer This bi-directional 8-bit buffer is used to interface the 8255 to the

    system data bus.

    Data is transmitted or received by the buffer upon execution of

    input or output instructions by the CPU. Control words information is transferred through the data bus

    buffer.

    ` Read/Write and Control Logic

    This block is to manage all of the internal and external transfers ofboth Data and Control words

    It accepts inputs from the CPU Address and Control busses and in

    turn, issues commands to both of the Control Groups

  • 8/3/2019 UNIT II Interfacing

    6/48

    ` (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

    ` (WR) Write

    A "low" on this input pin enables the CPU to write data or

    control words into the 8255

  • 8/3/2019 UNIT II Interfacing

    7/48

    ` (A0 andA1) 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

  • 8/3/2019 UNIT II Interfacing

    8/48

    Control Word Register

  • 8/3/2019 UNIT II Interfacing

    9/48

  • 8/3/2019 UNIT II Interfacing

    10/48

    ` Group A and Group B Controls The CPU "outputs" a control word to the 8255

    The control word contains information such as "mode", "bit set",

    "bit reset", etc.

    Each of the Control blocks (Group A and Group B) accepts"commands" from the Read/Write Control logic, receives "control

    words" from the internal data bus and issues the proper commands

    to its associated ports

    ` There are 2 basic modes of operations

    I/O Mode (Mode 0,Mode1 & Mode2)

    Bit Set Reset mode (BSR)

  • 8/3/2019 UNIT II Interfacing

    11/48

    BSR Mode

    ` In this mode any of the 8 bit of port C can be set orreset depending on D0 of the control word

    ` The bit to be set or reset is selected by D1,D2 & D3 of

    the control word register

  • 8/3/2019 UNIT II Interfacing

    12/48

    ` Eg: If the 5th bit (PC5) of port C has to be "SET", then what is thecontrol word?

    1. Since it is BSR mode, D7 = '0'.

    2. Since D4,D5,D6 are not used, assume them to be '0'.

    3. PC5 has to be selected, hence, D3 = '1', D2 = '0', D1 = '1'.4. PC5 has to be set, hence, D0 = '1'.

    Applying the above values to the format for BSR mode, we get the

    control word as "0B (hex)".

  • 8/3/2019 UNIT II Interfacing

    13/48

    Mode 0(Basic I/O mode)

    ` Features of this mode

    Two 8-bit ports ( port A and port B )and two 4-bit ports (port C upperand lower ) are available. The two 4-bit ports can be combinedly used as athird 8-bit port.

    Any port can be used as an input or output port

    Output ports are latched. Input ports are not latched

    A maximum of four ports are available so that overall 16 I/O configuration

    are possible.

    All these modes can be selected by programming the Control wordregister. CWR has two formats one for BSR mode and I/O modes

  • 8/3/2019 UNIT II Interfacing

    14/48

    Mode 1 (Strobed I/O mode)

    ` In this mode hand shaking signals controls the i/o operation` Port C lines PC0,PC1 & PC2 provides the handshake signals for

    port B

    ` Port C lines P3,PC6 & PC7 provides the handshake signals for port

    A

    ` PC4 & PC5 can be used as independent I/O lines

    Input Control Signal Definitions

    ` STB(Strobe input) : when it is low, data from the data lines are

    loaded into the latches

    ` IBF (Input buffer full):if it rises high, indicates data loaded into

    latches ( Acknowledgement )

  • 8/3/2019 UNIT II Interfacing

    15/48

    ` INTR (Interrupt Request ):used to interrupt the CPU and to get theservice by the input device

    ` INTE is the internal flag controlled by the bit set/reset mode either

    PC4 or PC2 as below

  • 8/3/2019 UNIT II Interfacing

    16/48

    Mode 1 Strobed Input Data Transfer

  • 8/3/2019 UNIT II Interfacing

    17/48

    Output control signal definition OBF(output buffer full):if low, indicates that CPU has written data to

    output

    ACK:acts as ack given by the output device

    INTR (Interrupt request ):used to interrupt the CPU when outputdevice ack the data receipt.

  • 8/3/2019 UNIT II Interfacing

    18/48

    Control word of A & Control word ofB

  • 8/3/2019 UNIT II Interfacing

    19/48

    Mode 1 Strobed output data transfer

  • 8/3/2019 UNIT II Interfacing

    20/48

    Mode 2(Strobed bi directional I/O)

    ` Only 8 bit in group A is available` The 8 bit port A is bidirectional & have 5 bit port control

    lines(PC3-PC7)

    ` 3 I/O lines are available at port C (PC2-PC0)

    ` Inputs and outputs are both latched

  • 8/3/2019 UNIT II Interfacing

    21/48

    Control signal definition in mode 2

    ` INTR(Interrupt request):used to interrupt the CPU to ask for data

    transfer

    Control signal for output operations

    ` OBF(output buffer full):If it is low ,indicates CPU has written data to

    port A

    ` ACK:If it is low ,indicates the ack for the received byte

    ` INTE1(Flag associated with OBF):controlled by PC6

  • 8/3/2019 UNIT II Interfacing

    22/48

    Control signal for input operations` STB(strobe input) :if Low, indicates the data into the input latches

    ` IBF(Input buffer full):when data is loaded into input buffer, raises to 1

    indicates data has been received by the receiver.

    Note: WR must occur before ACK and STB must be activated beforeRD.

  • 8/3/2019 UNIT II Interfacing

    23/48

  • 8/3/2019 UNIT II Interfacing

    24/48

    Mode 2 control word & Pins

  • 8/3/2019 UNIT II Interfacing

    25/48

    Serial I/O Interface -8251

    ` Introduction To begin with serial I/O there are certain terms and acronyms has

    to be explained they are

    Simple ,Half duplex and full duplex

    Synchronous or asynchronous In synchronous transmission data is sent in blocks at constant rates,

    start and the end of blocks are identified with specific bytes or bit

    pattern

    In asynchronous transmission each data character has a bit which

    identifies its start and 1 or 2 bits which identity its end

  • 8/3/2019 UNIT II Interfacing

    26/48

    ` Baud Rate- indicates the rate at which serial data is beingtransferred. Given as 1/(time between signal transmission)

    ` Serial data transmission are slow when compared to parallel data

    transmission

    ` Parallel data transmission requires more wires which makes difficult

    for transmitting data over a long distance

    ` Intel introduced 8251 a programmable synchronous orasynchronous communication offen called as universal synchronous

    asynchronous receiver and transmitter or USART

  • 8/3/2019 UNIT II Interfacing

    27/48

    ` Microcomputer always deals with parallel data, Hence before doingserial communication the data has to converted into serial data

    ` For sending serial data over a long distance, telephone lines were

    used

    ` For this the digital data has to converted into audio frequency

    signal which can transmit through phone lines

    ` The device used for conversion is called a modem

  • 8/3/2019 UNIT II Interfacing

    28/48

    ` Data and handshaking signals in sequence When the terminal is switched on, It assertsData-Terminal-Ready(DTR)

    to tell the modem it is ready

    Modem asserts Data-Set-Ready (DSR) to the terminal

    Modem dials the remote computer ,if it is available. Terminal has acharacter ready to send, it will assert Request-To-Send (RTS) signal

    The modem will send Carrier-Detect signal to the terminal indicating aconnection establishment

    The modem will assert a Clear-To Send signal (CTS) back to the terminal

  • 8/3/2019 UNIT II Interfacing

    29/48

    8251 block diagram

  • 8/3/2019 UNIT II Interfacing

    30/48

    PIN Description

    ` D7-D0 connect system bus to device` CS-used for address decoding

    ` 8251 has two internal addresses, a control address(FFF2H) which is

    selected when C/D is high and a data address (FFF0H)when the C/D

    is low

    ` RD,WR,RD & RESET are connected to the system signals

    ` TXC,RXC transmitter clock and receiver clock for shifting the data,

    used to select the frequency signal 1,16 or 64 times the baud rate

    ` CLK system clock signal

    ` TXD- indicates serial-data output

    ` RXD-indicates serial-data input

  • 8/3/2019 UNIT II Interfacing

    31/48

    ` TXE-Transmitter buffer empty` TXRDY Transmitter ready (ready for char from CPU)

    ` RXRDY-Receiver ready (has a character for CPU)

    ` SYNDET/BD-Sync detect /Break detect

    CONTROL WORDS

    There are two types of control word and a status word

    1. Mode word

    2. Command word3.Status word

    It is possible to see the internal status of the 8251 by reading the

    Status word

  • 8/3/2019 UNIT II Interfacing

    32/48

    Mode Word-Asynchronous

  • 8/3/2019 UNIT II Interfacing

    33/48

    Mode Word Synchronous

  • 8/3/2019 UNIT II Interfacing

    34/48

    Command Word

  • 8/3/2019 UNIT II Interfacing

    35/48

    Status Word

    ` D0-Indicates USART is ready to accept a data character orcommand

    ` D1-indicates USART has received the Character and ready totransfer it to the CPU

    ` D2-indicates parallel to serial converter is empty

    ` D3-Parity error

    ` D4-Over Run error-Indicates CPU does not read a character beforethe next one becomes available

    ` D5-Framing Error-Set when valid stop is not detected

    ` D6-Sync Detect-Indicates that the character sync has been achieved

    ` D7-used to test modem condition

  • 8/3/2019 UNIT II Interfacing

    36/48

    DMA controller 8257

    ` Direct Memory Access--the ability of an I/O subsystem totransfer data to and from a memory subsystem without

    processor intervention.

    ` DMA Controller--a device that can control data transfersbetween an I/O subsystem and a memory subsystem in

    the same manner that a processor can control such

    transfers

  • 8/3/2019 UNIT II Interfacing

    37/48

    DMA Controller Interfaced with the CPU

  • 8/3/2019 UNIT II Interfacing

    38/48

    Features of 8257

    ` It is programmable,4 channel direct memory access controller

    ` Each channel can programmed individually

    ` Each channel has a pair of 16 bit registers viz DMA address register

    and terminal counter registers

    ` Address register gives the address of the memory location &counter specifies the number DMA cycles to be performed

    ` It maintains a DMA cycle count for each channel and activates theTC signal to indicate the peripheral that specified DMA cycles arecompleted

  • 8/3/2019 UNIT II Interfacing

    39/48

    Pin Configuration`

    It has priority logic that resolves theperipheral request. Can be programmed

    in two modes either fixed or rotating mode

    ` D0-D7( Bidirectional pins connected

    to system bus

    ` Address Bus(A0-A3 & A4-A7)

    ` Address Strobe (ADSTB)-used to

    demultiplex higher byte address and

    data using external latch

  • 8/3/2019 UNIT II Interfacing

    40/48

    ` Address Enable (AEN)-indicates available of higher address on the latches

    ` Memory Read/Memory Write(MEMR,MEMW)

    ` I/O Read / I/O Write (IOR,IOW)

    ` Chip Select(CS)

    ` Hold Request-it is used for requesting the CPU to get the control of the

    system bus

    ` Hold Ack(HLDA) -indicates that CPU has granted the system bus

  • 8/3/2019 UNIT II Interfacing

    41/48

    ` DREQ0 DREQ3 -these are DMA request

    ` DACK0-DACK3 these are the ack for DMA request

    ` Terminal Count it indicates the completion ofDMA cycle

    ` MARK notifies the peripherals that current DMA cycle is 128th

    cycle since the previous MARK.

  • 8/3/2019 UNIT II Interfacing

    42/48

    Architecture of 8257

  • 8/3/2019 UNIT II Interfacing

    43/48

    ` Data buffers-there is a 8 bit buffer which interface the 8257 tosystem bus.

    In slave mode, it is used to transfer data between CPU and internal

    registers of 8257

    In master mode, it is used to send higher byte address on the data

    bus

    ` DMA Channels:

    8257 has 4 separate channels CH0 to CH1.each channel has a pair

    of 2 16 bit registers.

    Also there are two common register for all the channels namelymode set & status registers

    CPU selects one of these 10 registers using address lines A0-A3

  • 8/3/2019 UNIT II Interfacing

    44/48

    ` DMA address register- used to store the starting address of thememory location

    ` Terminal Count registers lower 14 bits are used count

    the required number ofDMA cycles

  • 8/3/2019 UNIT II Interfacing

    45/48

    ` T1 & T2 indicates the type ofDMA operation

    ` Mode Register

  • 8/3/2019 UNIT II Interfacing

    46/48

    ` B0-B3 bits enable one of the four DMA channels

    ` B4(Rotating priority) - is set enables rotating priority otherwise

    normal

    ` B6 (TC) -bit is set selected channel is disabled after the terminal

    count condition is reached & further prevents any DMA cycle on

    the channel

    ` If the TC stop bit is set to zero the channel is not disabled evenafter the count reaches zero

  • 8/3/2019 UNIT II Interfacing

    47/48

    ` B7- auto load bit is set enables channel 2 for repeat block chainingoperation.

    ` Channel 2 register are reloaded with the corresponding channel 3

    register for the next block transfer

    ` B6 (Extended write)- if set then extends the duration of MEMW

    and IOW.used while interfacing with slow devices.

  • 8/3/2019 UNIT II Interfacing

    48/48

    Status Register