Serial logging is a powerful tool in embedded systems. When limited by hardware, this note describes how to implement a minimal UART logger using only one TX GPIO pin and a USB-to-Serial adapter.
Configure UART in software if no hardware USART is available:
void uart_init(void) { UBRRH = 0; UBRRL = 51; // 9600 baud at 8 MHz UCSRB = (1 << TXEN); UCSRC = (1 << URSEL) | (3 << UCSZ0); } void uart_putc(char c) { while (!(UCSRA & (1 << UDRE))); UDR = c; } void uart_puts(const char* s) { while (*s) uart_putc(*s++); }
screen /dev/ttyUSB0 9600