Elective Microprocessor Based Design

Microprocessor Based DesignUnit 311 min read

Bus & Communication Tech: Protocols, Topologies & Interfaces

Unit 3 of Microprocessor Based Design explores how microcontrollers communicate via buses (data, address, control), serial/parallel interfaces, and protocols (I²C, SPI, UART), with real-world applications in embedded systems like traffic lights and IoT sensors.

TAKEAWAYS:

  • Buses (data, address, control) are the "highways" for microcontroller communication, with handshaking ensuring data integrity.
  • Serial vs. parallel interfaces differ in speed, wiring complexity, and use cases (e.g., SPI for sensors, UART for debugging).
  • Communication protocols (I²C, SPI, UART) define rules for data exchange, including clock synchronization and error handling.
  • Topologies (star, bus, ring) determine how devices connect, affecting fault tolerance and scalability.
  • Electromagnetic interference (EMI) disrupts signals; shielding and grounding mitigate it in real hardware.
  • Real-world systems (e.g., eSewa’s payment queues, NTC’s network routing) rely on these principles for reliability.

1. Introduction to Buses in Microcontrollers

Microcontrollers (MCUs) like the 8051 communicate with peripherals (sensors, memory, displays) via buses: shared pathways for data, addresses, and control signals. Buses are classified into three types:

1.1 Types of Buses

Data BusBidirectionalAddress BusUnidirectional (MCU → Peripherals)Control BusUnidirectional/Bidirectional
Types of Buses in Microprocessor Systems (8/16/32-bit width shown for Data Bus)
  • Data Bus: Bidirectional, carries data/instructions (e.g., 8-bit in 8051).
  • Address Bus: Unidirectional (MCU → memory/I/O), selects memory locations (e.g., 16-bit in 8051 for 64KB address space).
  • Control Bus: Manages operations like READ, WRITE, RESET, and interrupts.

Worked Example: 8051 Bus Operation When the 8051 reads data from memory location 2000H:

  1. Address 2000H is sent via Address Bus.
  2. Control Bus asserts READ signal.
  3. Data from 2000H appears on the Data Bus and is latched into the MCU.


2. Serial vs. Parallel Communication

2.1 Parallel Communication

  • Definition: Multiple data bits transmitted simultaneously over separate wires.
  • Example: Printer ports (8-bit data lines + control signals).
  • Advantages:
    • Faster data transfer (e.g., 8 bits at once).
  • Disadvantages:
    • More wiring (costly, prone to skew).
    • Limited to short distances (signal degradation).
  • Use Case: High-speed peripherals like VGA monitors.

2.2 Serial Communication

  • Definition: Data transmitted one bit at a time over a single wire (or pair).
  • Types:
    • Asynchronous (UART): No clock signal (e.g., Bluetooth, GPS modules).
    • Synchronous (SPI, I²C): Requires clock synchronization.
  • Advantages:
    • Fewer wires (cost-effective, long-distance).
    • Built-in error detection (parity bits, checksums).
  • Disadvantages:
    • Slower than parallel (but often sufficient for sensors).
  • Use Case: IoT devices (e.g., DHT11 temperature sensor via UART).

Comparison Table:

Feature Parallel Serial (UART/SPI/I²C)
Data Lines 8+ wires 1–4 wires
Speed High (MHz) Low (kbps–Mbps)
Distance <1m Up to 100m (with drivers)
Complexity High (handshaking needed) Low (protocol-managed)
Example Printer port Arduino → Sensor (UART)


3. Key Communication Protocols

3.1 UART (Universal Asynchronous Receiver/Transmitter)

  • How it Works:
    • Asynchronous: No clock signal; sender/receiver must agree on baud rate (e.g., 9600 bps).
    • Frame format: Start bit (1) → Data (8/9 bits) → Parity (optional) → Stop bit (1).
  • Example: Debugging via USB-to-UART adapters (e.g., FTDI chips).
  • Advantages: Simple, widely supported.
  • Disadvantages: No built-in error correction.
Start Bit (0)Data Bits (8 bits:10010101)Parity Bit(optional)Stop Bit (1)
UART Frame Format (Example: 8N1 Configuration)

3.2 SPI (Serial Peripheral Interface)

  • How it Works:
    • Synchronous: Uses a clock (SCLK) signal.
    • Full-duplex: Master (MCU) and slave (sensor) transmit simultaneously.
    • 4 Wires: SCLK, MOSI (Master Out Slave In), MISO (Master In Slave Out), SS (Slave Select).
  • Example: Reading an MPU6050 accelerometer.
  • Advantages: High speed (up to 10 Mbps), no handshaking.
  • Disadvantages: More wires than I²C; no built-in addressing.
MCU (Master)Sensor (Slave)
SPI 4-Wire Full-Duplex Communication

3.3 I²C (Inter-Integrated Circuit)

  • How it Works:
    • Synchronous, half-duplex: Uses SDA (data) and SCL (clock) lines.
    • 7-bit or 10-bit addressing: Multiple slaves on the same bus.
    • Pull-up resistors: Open-drain buses require external resistors (typically 4.7kΩ).
  • Example: Connecting an OLED display to an Arduino.
  • Advantages: Few wires, supports multiple devices.
  • Disadvantages: Slower than SPI (100 kbps–400 kbps); sensitive to noise.
MCU (Master)Slave1 (EEPROM 0x50)Pull-Up Resistors (4.7kΩ)
I²C Bus with Pull-Up Resistors (Open-Drain Logic)


4. Network Topologies in Embedded Systems

Topologies define how devices connect in a network. Common types:

4.1 Bus Topology

  • Structure: All devices share a single communication line.
  • Example: 1-Wire bus (DS18B20 temperature sensor).
  • Advantages: Simple, cost-effective.
  • Disadvantages: Single point of failure; limited scalability.

4.2 Star Topology

  • Structure: All devices connect to a central hub (e.g., MCU).
  • Example: Ethernet in home networks.
  • Advantages: Easy to add/remove devices; fault isolation.
  • Disadvantages: Central hub is a single point of failure.

4.3 Ring Topology

  • Structure: Devices connected in a closed loop.
  • Example: Token-passing networks (rare in MCUs).
  • Advantages: Equal access; no collisions.
  • Disadvantages: Complex; failure in one node breaks the ring.
MCUSensor1Sensor2Sensor3
Ring Topology (Token-Passing Mechanism)


5. Electromagnetic Interference (EMI) and Solutions

EMI disrupts signals in buses/protocols. Sources include:

  • Power lines (50/60Hz noise).
  • Motors, relays, or other digital circuits.
  • Poor grounding.

5.1 Mitigation Techniques

Technique Description Example
Shielding Metal enclosure blocks EMI (e.g., twisted-pair cables). Ethernet cables
Grounding Common ground reduces noise loops. Star grounding in PCBs
Filtering Capacitors/inductors filter high-frequency noise. Decoupling capacitors on MCU
Twisted-Pair Wiring Reduces radiated EMI by canceling magnetic fields. UART TX/RX lines
Keepout Zones Separate noisy components (e.g., motors) from sensitive circuits. PCB layout rules

Real-World Example: NTC’s Fiber-Optic Networks Nepal Telecom uses fiber-optic cables to minimize EMI in long-distance communication. Unlike copper wires, fiber is immune to electromagnetic interference, ensuring stable internet in hilly regions.



6. Real-World Applications

6.1 eSewa’s Payment Queue (FIFO Buffer)

eSewa uses serial communication (UART/SPI) to process transactions. When you pay via mobile:

  1. Your phone sends a UART request to eSewa’s server.
  2. The server processes it in a FIFO queue (first-in-first-out), ensuring fairness.
  3. I²C may be used internally to read data from the SIM card.
Transaction1Transaction2Transaction3FRONTREARoutin
FIFO Buffer Processing (eSewa Payment Queue)

6.2 Pathao’s GPS Tracking (UART)

Pathao’s driver app receives GPS coordinates via UART from the phone’s GPS module. The MCU in the phone:

  • Reads NMEA data (serial protocol) from the GPS.
  • Sends location updates to Pathao’s servers via Wi-Fi (IEEE 802.11).
02467Start1 bitsData (7 bits)7 bitsParity1 bitsStop1 bits
NMEA GPS Sentence UART Frame (Example: $GPRMC)

6.3 NEPSE Stock Data (SPI)

Nepal’s stock exchange (NEPSE) uses high-speed SPI buses to transmit real-time stock data to trading terminals. The low latency of SPI ensures traders get updates faster than with UART.



Exam Tip

  1. Bus Operations: Always trace the flow of data/address/control signals in questions (e.g., "How does the 8051 read from memory?").
  2. Protocol Differences:
    • UART: Asynchronous, no clock, simple.
    • SPI: Synchronous, full-duplex, 4 wires.
    • I²C: Synchronous, half-duplex, 2 wires + addressing.
  3. Topologies: Know when to use bus (simple), star (scalable), or ring (rare in MCUs).
  4. EMI Solutions: Expect questions on shielding, grounding, or twisted-pair wiring.
  5. Worked Examples: Practice calculating baud rates (e.g., "A UART transmits 10 bits at 9600 bps. What’s the time per bit?").
  6. Real-World Links: Relate protocols to systems like eSewa (UART for payments), Pathao (GPS UART), or NTC (fiber-optic EMI resistance).

Key Formula to Remember:

  • Baud Rate Calculation: Example: For a 9600 bps UART, each bit takes .

Based on the TU BSc CSIT syllabus for Microprocessor Based Design, unit 3.

Discussion

Loading…