- 2076 Chaitra · 9 marks
8255 mode 1 keyboard and printer with decoding
Short answer
Port addresses: A=FCH, B=FDH, C=FEH, Control=FFH (A7–A2=111111). Control word B4H sets port A mode 1 input, B mode 1 output. BSR word 09H enables INTEA; OBFB' mask is 02H. Keyboard ISR reads port A, sets flag; main loop calls write routine that polls OBFB' then outputs to port B.
Port A is to design as the input for a keyboard in interrupt driven I/O and Port B as the output for a printer in status check I/O using mode 1 of 8255 with 8085 microprocessor as shown below: (a) Find port addresses by analyzing decoding logic. (b) Determine the control word to set up port A as input and port B as output. (c) Determine the BSR word to enable INTEA. (d) Determine the masking byte to verify the OBFB line. (e) Write main program and a read and write subroutines to accept characters from keyboard and to send them to print. [Figure: 8255 with +5 V on Vcc and GND; data bus D7-D0. A multi-input NAND gate with inputs A7, A6, A5, A4, A3, A2 drives CS (active low). A1 and A0 connect to the 8255 A1 and A0. IOR connects to RD and IOW to WR; RESET OUT connects to RESET. Port A (PA7-PA0) is the input from the keyboard. PC4 is STB (active low) from the peripheral; PC5 is IBF to the peripheral; PC3 is INTRA going to the 8085 interrupt RST 6.5. PC1 is OBFB (to the printer); PC2 is ACKB (from the printer). Port B (PB7-PB0) is the output to the parallel printer.]
(a) Port addresses
CS' = NAND(A7, A6, A5, A4, A3, A2), so the chip is selected only when A7-A2 = 111111. Port A = FCH (1111 1100), Port B = FDH, Port C = FEH, Control = FFH (I/O mapped, IOR'/IOW').
(b) Control word
Port A mode 1 input; port B mode 1 output. D7 = 1; D6D5 = 01; D4 = 1 (A input); D3 = 0 (PC6, PC7 output); D2 = 1 (B mode 1); D1 = 0 (B output); D0 = 0 = 1011 0100 = B4H.
(c) BSR word to enable INTEA
In mode 1 input, INTE_A is controlled by PC4. D7 = 0, D3D2D1 = 100, D0 = 1: 0000 1001 = 09H. (INTR_A on PC3 goes to RST 6.5, vector 0034H.)
(d) Masking byte for OBFB
Port C status word (A input, B output): D7 D6 I/O, D5 IBF_A, D4 INTE_A, D3 INTR_A, D2 INTE_B, D1 OBF_B', D0 INTR_B. OBFB' is bit D1, so the mask is 0000 0010 = 02H. OBF_B' = 1 means the printer has accepted the last byte.
(e) Program
ORG 0034H ; RST 6.5 vector
JMP KBDISR
ORG 2000H
START: LXI SP,27FFH
MVI A,B4H
OUT FFH ; mode set
MVI A,09H
OUT FFH ; INTEA = 1
MVI A,0DH ; SIM: unmask RST 6.5 (MSE=1, M7.5=1, M6.5=0, M5.5=1)
SIM
EI
LXI H,3000H ; buffer pointer
MVI D,00H ; D = 1 when a character has arrived
MAIN: MOV A,D
ORA A
JZ MAIN ; wait for keyboard interrupt
MVI D,00H
CALL WRITE ; print the character
JMP MAIN
KBDISR: PUSH PSW ; read subroutine (interrupt service)
IN FCH ; read keyboard character from port A
MOV M,A ; store in buffer
MVI D,01H ; flag
POP PSW
EI
RET
WRITE: IN FEH ; write subroutine: read port C
ANI 02H ; mask OBFB'
JZ WRITE ; wait until printer has taken last byte
MOV A,M
OUT FDH ; send character to printer
INX H
RET
The keyboard needs interrupt service because key presses are random; the printer is slow, so its status is checked before each byte.
✓ Answer checked by Claude Sonnet 5.5
Related questions
- Keyboard and printer interface in 8255 mode 1 · Instrumentation II, chapter 2
- Keyboard and printer with 8255A at 4044H · Instrumentation II, chapter 2
- Centronics printer with 8255A in mode 1 · Instrumentation II, chapter 2
- 8255A at 80H: addresses, mode 0/1 words, BSR · Instrumentation II, chapter 2
- 8255A card at F3H with keyboard and display · Instrumentation II, chapter 2
- ADC804 with 8255 control word and program · Instrumentation II, chapter 4
- Address decoding for input and output ports · Microprocessor, chapter 4
- Address decoding for input port at 8050H · Microprocessor, chapter 4
- Address decoding for 8 LEDs output port · Microprocessor, chapter 4