Serial Communication for debugging - dummies version


If you are older than 28 years old, you might already know what a COM port looks like. Yes, COM port stands for Communication port. It was used widely to connect external device to the computer in the old days around 2005, such as: modem, mouse, even printer or transfer data between 2 PCs. Yes, COM port was understood as serial port.


But you won’t see it in modern PC, simply because Com port is so slow 115200 bit/second compare to USB2.0 480 Megabit/second. But this is not the case for 8bit microcontroller which usually clock at 16Mhz. And this slow speed connection is very handy since microcontrollers nowadays they all support serial connection.

People call it UART - Universal asynchronous receiver/transmitter.

This post won’t go into details how UART works and the stuffs behind the scene, but just some tips that help you catch the data that flowing out from the microcontroller.

The basics

Most microcontrollers such as AVR, PIC, ARM… operate at 5vDC or 3.3vDC. So are the input / output signal is about 5v or 3.3v for HIGH level and 0v for LOW level. Since it is TTL (Transistor-Transistor Logic) circuit, there is voltage drop across the transistor in the output circuit of microcontroller. So, it won’t be exactly 5v, but who cares?

You need just 3 wires for serial communication: RX, TX, GND. But usually for a single chip microcontroller, you need to another wire for Vcc


Set up the connection

Okay, you have 3 wires from the microcotrollers, then how do you connect it to the PC? Not quite simple. Even your PC has a COM port, you have to get into the trouble of a signal converter to get 5v signal to 12v signal of COM port, which is RS232.


You can use Max232 to convert UART from TTL circuit to RS232 protocol so you can directy connect do COM port on the CPU back panel


But why go into trouble even if you have a real COM port? You can just use a simpler solution by a USB to UART converter like This


Software side

The hardware is set up, then you need to know which COM port is using


Open Putty and listening the messages from your microcontroller.


Get debug information of other devices

Yeah, you can connect PC to pretty much everything using serial connection: wifi router, android TV box, bluetooth module, cellphone… as long as it has UART port. This can be extreme useful when recover your precious device from a brick state (aka flashing the wrong ROM).

This is my fail safe plan to rescue Linksys AE4500 if flashing openwrt firmware doesn’t go well. Thanks to U-Boot of Mavell that support flashing firmware via UART.

Real action - baud rate 115200

Since this android board just dumps debug data out on UART, it doesn’t really stop and accept input from UART. Anyway, it’s good to know it’s still working even if it fails to boot.

Real action - baud rate 115200


Add comment

Fill out the form below to add your own comments

User data

Add your comment

[color=red] TEXT [/color]
[quote] TEXT [/quote]
[code=arduino avrasm cpp css java javascript nginx perl python] TEXT [/code]
Clear format