Skip to main content

Port-based and bus-based I/O

Short answer

Port-based I/O connects peripherals directly to processor port pins, accessed as registers (e.g., 8051 SFRs) without buses. Bus-based I/O attaches peripherals to system buses, requiring address decoding and using memory-mapped or isolated I/O. The 8051 primarily uses port-based I/O via its four 8-bit ports.

Explain port-based and bus-based I/O. (Which I/O, port based or bus based, is used in the 8051 microcontroller? Describe in brief.)

Port-based I/O

The processor has special I/O ports built into it and the peripheral is connected directly to the port pins. The port is seen by the programmer as one or more registers (special function registers) read and written like ordinary registers, e.g. MOV P1, A or MOV A, P1. No address or data bus is used for the peripheral. Example: reading a switch on P1 and driving an LED on P2.

Bus-based I/O

The processor has address, data and control buses, and the peripherals are attached to these buses. It uses special logic (address decoder and registers) to access them, either as memory-mapped I/O (same instructions as memory) or standard (isolated) I/O (IN/OUT instructions). The processor reads or writes a peripheral by placing its address on the bus. Example: a UART connected to a microprocessor bus.

PointPort-basedBus-based
AccessDirect register/pin accessThrough address, data and control buses
InstructionsNormal register instructionsMemory or IN/OUT instructions
HardwareSimple, no decoderNeeds address decoding
Number of peripheralsLimited by number of pinsMany

In the 8051

The 8051 mainly uses port-based I/O: four 8-bit parallel ports P0, P1, P2 and P3 (32 pins), which are special function registers that can be bit-addressed (SETB P1.0). Peripheral registers such as timers and serial port (SBUF, TMOD, SCON) are also accessed as SFRs. The 8051 can also use a bus (P0 as multiplexed address/data, P2 as high address) for external memory and memory-mapped peripherals, but in that case ports P0 and P2 are no longer available as I/O ports.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Embedded System chapter 5 questions →