Skip to main content

Master-slave 8085 bidirectional communication via 8255

Short answer

Each 8085 has an 8255 at I/O addresses 80H–83H. Master control word A6H configures port A mode 1 output and B input; slave B4H sets A input and B output. For 100 bytes, master polls OBF_A' before writing; slave polls IBF_A before reading.

Design an interfacing circuit to set up bidirectional data communication in the master-slave format between two 8085A microcomputers. Use the 8255A as the interfacing chip between the master and the slave microcomputers. What will be the port addresses and control word. Write necessary program to transfer a block of data from the master to the slave along with its flowchart diagram.

Idea

Each microcomputer has its own 8255A. Two 8-bit channels in mode 1 are provided so that data can flow in both directions: port A carries data master -> slave (master port A mode 1 output, slave port A mode 1 input), and port B carries data slave -> master (slave port B mode 1 output, master port B mode 1 input). The handshake lines are cross connected, which gives bidirectional communication (master-slave format).

Interfacing circuit

     MASTER 8255                      SLAVE 8255
 PA0-PA7 =========== 8-bit bus =====> PA0-PA7      (M -> S)
 PC7 OBF_A' ----------------------->  PC4 STB_A'
 PC6 ACK_A' <------[NOT]-----------   PC5 IBF_A
 PB0-PB7 <========= 8-bit bus ======  PB0-PB7      (S -> M)
 PC2 STB_B' <-----------------------  PC1 OBF_B'
 PC1 IBF_B  -------[NOT]----------->  PC2 ACK_B'
 PC3 INTR_A / PC0 INTR_B -> master RST inputs (optional)
 Common GND

Rule: OBF' of the sender goes to STB' of the receiver; IBF of the receiver, inverted, goes to ACK' of the sender. In mode 1 output the data stay latched on the port pins, so the receiver can take them when STB' falls.

Port addresses (each system I/O mapped, A7 = 1, A6-A2 = 0)

Port A = 80H, Port B = 81H, Port C = 82H, Control = 83H.

Control words

  • Master: A mode 1 output, B mode 1 input: 1 01 0 0 1 1 0 = A6H.
  • Slave: A mode 1 input, B mode 1 output: 1 01 1 0 1 0 0 = B4H.

Programs: transfer a block of 100 bytes from master to slave

Master (source 2000H):

        MVI A,A6H
        OUT 83H
        LXI H,2000H     ; source block
        MVI B,64H       ; 100 bytes
SEND:   IN 82H
        ANI 80H         ; OBF_A' = 1 means port free (last byte taken)
        JZ SEND
        MOV A,M
        OUT 80H         ; byte to port A, OBF_A' goes low
        INX H
        DCR B
        JNZ SEND
        HLT

Slave (destination 3000H):

        MVI A,B4H
        OUT 83H
        LXI H,3000H
        MVI C,64H
RECV:   IN 82H
        ANI 20H         ; IBF_A = 1 means a byte arrived
        JZ RECV
        IN 80H          ; read byte, IBF_A cleared, master gets ACK
        MOV M,A
        INX H
        DCR C
        JNZ RECV
        HLT

Flowchart

 Master                     Slave
 Initialise 8255 (A6H)      Initialise 8255 (B4H)
 HL = source, B = count     HL = destination, C = count
 Read port C                Read port C
 OBF_A' = 1? --no--> loop   IBF_A = 1? --no--> loop
 | yes                      | yes
 Send byte (OUT 80H)        Read byte (IN 80H), store
 HL+1, B-1                  HL+1, C-1
 B = 0? --no--> loop        C = 0? --no--> loop
 | yes                      | yes
 Stop                       Stop

For slave -> master transfer the same routines are used with port B (81H) and the bits OBF_B' (D1) and IBF_B (D1) of port C.

✓ Answer checked by Claude Sonnet 5.5

All Instrumentation II chapter 2 questions →