EMBEDDED SYSTEMS & MICROCONTROLLERS · PAGE 18
Debugging Firmware
Finding bugs when you cannot see inside the chip.
The simplest tools are an LED you toggle at key points and text sent over UART. Print values, not guesses.
A hardware debugger connects to dedicated pins and lets you pause the CPU, step through lines and inspect registers. A logic analyser or oscilloscope shows what the pins really do.
Common causes: uninitialised variables, stack overflow, missing volatile, wrong clock settings and floating inputs. Change one thing at a time.