INTERFACING
(GPIO, UART,
SPI, I²C)
Module 3
GPIO(General Purpose Input output)
◦ GPIO pins are basic digital pins used for direct control and monitoring of signals (HIGH/LOW)
◦ GPIO can be configured as input or output using instructions. In 8051: P0,P1,P2,P3 are GPIO ports.
P1 is dedicated I/O.
◦ P1,P2,P3 has internal pull-up resistors, while P0 is open drain.
Key features: Applications: Limitations:
• Simple ON/OFF control • LED control • No built-in
• Can act as input or • Switch/button communication
output interfacing structure
• No protocol i.e manual • Relay driving • High CPU
control required involvement
• Supports interrupts in • Not scalable for
some MCUs complex
communication
UART (Universal Asynchronous Receiver Transmitter)
◦ UART is an asynchronous serial communication protocol—no clock line required
◦ Generally, it requires two lines only, Rx and Tx.
Start bit Data bits Parity Stop bit
Key features: Application: Limitations:
• Very simple design • PC to Microcontroller • Only point-to-point
• Uses TX (Transmit) and RX communication • Speed limited
(Receive) • GPS, Bluetooth modules compared to SPI
• Full-duplex communication • Debugging logs • No inherent
• Configurable for different
addressing
baud rate i.e 9600, 115200
• Parity bit optional
UART
SPI (Serial Peripheral Interface)
◦ SPI is a synchronous 4 wire, high-speed full-duplex communication protocol using a clock signal.
◦ Originally developed by Motorola in 1980s.
Key features: Limitations:
• Very high speed (MHz Applications:
• Requires more wires
range) • ADC/DAC interfacing
• No standard addressing
• Full-duplex communication • Flash memory
(uses chip select lines)
• Simple hardware logic • Sensors and displays
• Poor scalability with many
• Master provides clock signal • Wired game controllers
slaves
• No error detection
Key signals involved:
• MOSI (Master Out Slave In)
• MISO (Master In Slave Out)
• SCLK (Clock)
• CS/SS (Chip Select/slave
select)
SPI
I²C (Inter-Integrated Circuit)
◦ I²C is a two-wire synchronous communication protocol with built-in addressing.
◦ Developed by Philips Semiconductors (now NXP Semiconductors) in the 1980s.
Key features: Applications: Limitations:
• Multi-master, multi-slave • Sensors (temperature, • Slower than SPI
support Inertial Measurement • More complex protocol
• Uses addressing (7-bit or Unit) • Susceptible to noise on long
10-bit) • EEPROM (Pen drive) lines
• Requires pull-up resistors • RTC (Real-Time Clock)
• Supports clock stretching
Signals used:
• SDA (Serial Data)
• SCL (Serial Clock)