
SPI Bus Debugging: When CPOL/CPHA Gets You at 3 AM
Clock polarity and phase mismatches are boring until your sensor returns all-zeros at midnight during bring-up. A systematic approach to sorting it out fast.
Microcontroller programming, real-time systems, IoT development, and firmware engineering

The 12-bit ADC on an STM32 rarely achieves 12 ENOB in practice. The gap between datasheet and bench is explained by supply noise, layout, and the reference — and fixable.

Clock polarity and phase mismatches are boring until your sensor returns all-zeros at midnight during bring-up. A systematic approach to sorting it out fast.

Writing to the same flash page on every sensor sample will kill the MCU before the product's warranty expires. Wear leveling strategies for internal flash.

Edge, pulse-width, serial decode, runt — a practical reference for the triggers I actually use when debugging firmware on real hardware.

A product that runs for months will fragment its heap in ways that 24-hour QA testing never reveals. Static allocation, pool allocators, and when to give up on dynamic memory.

Thermal systems have large time constants and pure dead time that make Ziegler-Nichols overshoot badly. What actually worked and how I validated it without an industrial process tool.

Most UART tutorials show 115200 baud where framing errors are rare. At 4 Mbaud the 3% tolerance in the spec becomes a real engineering constraint.

A Black Magic Probe built from a $4 STM32F103 board gives you a GDB server directly over USB. Setup, SWD pinout, and the one gotcha on multi-core targets.

SWD uses two wires vs JTAG's four and works fine for single-core flashing and debugging. The cases where JTAG's daisy-chain and boundary scan capabilities are worth the extra pins.