---
title: "8255 mode 0 DIP switches and LEDs"
subject: "Instrumentation II"
chapter: 2
key: "semester_5/instrumentation_ii:ppi-mode0-dip-leds"
source: https://www.bctengineer.com/q/semester_5/instrumentation_ii/ppi-mode0-dip-leds
site: BCT Engineering
---

# 8255 mode 0 DIP switches and LEDs

Instrumentation II · Chapter 2: Parallel Interfacing With Microprocessor Based System

- Asked in: 2079 Baisakh, 2+2+1+3 marks
- Video: [Control Word and Modes of 8255: BSR Mode, IO Modes, and Detailed Mode 0, 1, & 2](https://www.youtube.com/watch?v=la-EoWUcSp4) — Engineering Funda
- Answer checked by Claude Sonnet 5.5 on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/instrumentation_ii/ppi-mode0-dip-leds
- Whole chapter: https://www.bctengineer.com/md/semester_5/instrumentation_ii/chapter-2

## Question

8255 is to be operated in mode 0. Port A and port C upper are designed as output for LEDs and port B and port C lower as input ports for DIP switches. Address line A15 is connected with CS of 8255 through an inverter. (a) Draw the complete mapping diagram. (b) Determine the port addresses. (c) Determine the control word. (d) Write a program to read the DIP switches and display the reading from port B at port A and C lower at port C upper.

## Short answer

Port A=8000H, B=8001H, C=8002H, Control=8003H (A15=1). Control word 83H sets A and C upper output, B and C lower input. Program reads port B switches, outputs to port A LEDs; reads port C lower switches, rotates to upper nibble, masks F0H, outputs to port C upper LEDs.

## Answer

#### (a) Mapping diagram (memory mapped, 8085)
A15 is connected to CS' through an inverter, so the 8255 is selected when A15 = 1; other lines A14-A2 are not decoded (partial decoding). A1, A0 select the registers.
```text
 A15 --[NOT]--> CS'
 A1 -> A1, A0 -> A0, RD' -> RD', WR' -> WR', RESET OUT -> RESET
 AD0-AD7 -> D0-D7
 PA0-PA7 -> 8 LEDs      PC4-PC7 -> 4 LEDs
 PB0-PB7 <- 8 DIP switches   PC0-PC3 <- 4 DIP switches
```

#### (b) Port addresses
With unused lines taken as 0: Port A = **8000H**, Port B = **8001H**, Port C = **8002H**, Control = **8003H** (images exist at every address with A15 = 1).

#### (c) Control word
Port A out (D4 = 0), C upper out (D3 = 0), B in (D1 = 1), C lower in (D0 = 1), mode 0 (D6 D5 D2 = 0), D7 = 1: 1000 0011 = **83H**.

#### (d) Program
```text
        MVI A,83H
        STA 8003H       ; initialise 8255
LOOP:   LDA 8001H       ; read DIP switches of port B
        STA 8000H       ; display on port A LEDs
        LDA 8002H       ; read port C (lower nibble = switches)
        RLC
        RLC
        RLC
        RLC             ; move lower nibble to upper nibble
        ANI F0H         ; clear lower nibble
        STA 8002H       ; display on port C upper LEDs
        JMP LOOP
```
Writing to the lower half of port C has no effect because it is an input, so only the upper LEDs change.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. With only A15 connected through an inverter to CS', what address range does the 8255 respond to?
   A. Any address with A15 = 1, so it has images
   B. Only 8000H-8003H
   C. Any address with A15 = 0
   D. Only 0000H-0003H
   Answer: A. A14-A2 are not decoded, so images exist at every address with A15 = 1. (Key point: Partial decoding)

2. Port A out, C upper out, B in, C lower in, mode 0. Control word?
   A. 93H
   B. 82H
   C. 8BH
   D. 83H
   Answer: D. D7=1, D4=0, D3=0, D1=1, D0=1 gives 1000 0011 = 83H. (Key point: Control word)

3. Why does the program rotate left four times before writing to port C?
   A. To clear the carry flag
   B. To switch port C to input
   C. To read port A
   D. To move the lower-nibble switch value into the upper nibble that drives the LEDs
   Answer: D. The switches are on PC0-PC3 but the LEDs are on PC4-PC7. (Key point: Nibble move)

## Related in Instrumentation II

- [8255 port addresses from decoder figure](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Appi-port-addresses-decoder-fig) — Instrumentation II, chapter 2
- [8255 mode 1 keyboard and printer with decoding](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Appi-keyboard-printer-mode1-fig) — Instrumentation II, chapter 2
- [Keyboard and printer interface in 8255 mode 1](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Akeyboard-printer-mode1) — Instrumentation II, chapter 2
- [8255 interface with switches and 7-segment](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Appi-switch-sevenseg) — Instrumentation II, chapter 2
- [8255 mode 2 operation with timing diagram](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Appi-mode2) — Instrumentation II, chapter 2
- [ADC at 80H with 8255A: display on port B LEDs](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Aadc-8255-80h-leds) — Instrumentation II, chapter 2

## Related in other subjects

- [Address decoding for 8 LEDs output port](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Adecoder-output-port-8-leds) — Microprocessor, chapter 4
- [Address decoding for input and output ports](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Adecoder-input-output-port-block-decoder) — Microprocessor, chapter 4
- [Address decoding for input port at 8050H](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Adecoder-input-port-lda-8050h) — Microprocessor, chapter 4
- [Blink 8 LEDs at port 2](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-blink-leds-port2) — Embedded System, chapter 9, asked 2×
