So far, we’ve been blinking LEDs and setting delays—but now it’s time for your microcontroller to talk.
Meet UART – the simplest and most popular method of serial communication in embedded systems.
💬 UART = Universal Asynchronous Receiver Transmitter
🧠 What is UART?
UART is a hardware peripheral that allows two devices to exchange data one bit at a time, over just two wires:
- TX (Transmit)
- RX (Receive)
It’s asynchronous, which means:
- No external clock line is needed.
- Both devices must agree on a baud rate (bits per second).
🔌 Common UART Applications
| Use Case | Example |
| Debugging via Serial | Serial monitor (USB ↔ UART) |
| MCU-to-MCU Communication | Master-slave setups |
| GPS Modules | Send NMEA strings to MCU |
| Bluetooth Modules | HC-05, HC-06 |
🔧 UART Communication Basics
Each character sent is framed like this:
Start Bit | Data Bits (usually 8) | Optional Parity | Stop Bit
Example: Sending character A (0x41)
Start | 0 0 0 0 0 0 1 0 | Stop
📟 Simple UART Code Example (Bare-Metal)
Let’s assume these are the UART register addresses (for demo only):
#define UART_TX_REG (*((volatile uint32_t*)0x4000C000))
#define UART_STATUS_REG (*((volatile uint32_t*)0x4000C004))
#define UART_TX_READY (1 << 0)
void uart_send(char c) {
while (!(UART_STATUS_REG & UART_TX_READY)); // Wait until TX ready
UART_TX_REG = c; // Send character
}
Send a string:
void uart_send_string(const char* str) {
while (*str) {
uart_send(*str++);
}
}
🧪 Real Use Case: Debugging
Want to see values in your embedded code without a screen? Just send it over UART:
char buffer[20];
sprintf(buffer, "Temp = %d\n", temp);
uart_send_string(buffer);
And view it in a Serial Terminal like:
- Arduino Serial Monitor
- PuTTY
- RealTerm
📘 UART Settings You Must Know
| Parameter | Typical Values |
| Baud Rate | 9600, 115200 |
| Data Bits | 8 |
| Parity | None, Even, Odd |
| Stop Bits | 1 |
| Flow Control | None (default) |
💡 Both devices must match these exactly!
🧰 Tools You’ll Need
- USB-to-Serial Converter (e.g., FTDI, CP2102)
- Serial Terminal Software
- Logic Analyzer (optional, for debugging)
⚠️ Pro Tip
UART is full-duplex—TX and RX can run at the same time—but not every implementation supports this well. Also, use interrupts or DMA for better performance in real-time systems.
🔍 Up Next (Day 8):
🧠 Interrupts – Stop Polling, Start Responding
Discover how microcontrollers respond instantly to events like button presses, sensor triggers, and more.






















