Back to Home

Microcontroller Debugging Errors: SWD and Hardware Bugs

The Article Analyzes Real Bug Cases in Microcontroller Development: Hardware Errors Like Debris in Connectors and Pin Conflicts, Software — Flash Configuration and FPU. Practical Solutions for Reliable Debugging of STM32, TI CC, nRF.

Epic MCU Bugs: from SWD to ESD and Crystals
Advertisement 728x90

# Common Hardware and Software Pitfalls in Microcontroller Debugging

Microcontroller firmware freezes: heartbeat LED stops blinking, UART console goes unresponsive. Classic symptom. Don't panic — systematically check stack traces, logs, and peripherals. The culprit is often something simple: debris in connectors, pin conflicts, or misconfigurations.

Hardware Traps: From Debris to Soldering Mishaps

Telematics board development for a CAN network: car won't start, starter spins uselessly. Three hours of diagnostics — cause found in OBD-II connector: a scrap of foil shorted three pins. Clearing the debris solved it.

Dense board layout with Tag-Connect: programming connector inaccessible due to nearby Traco Power regulator. Clip won't latch — fingers can't reach. Solution: rope in colleagues with slim fingers or redesign the layout.

Google AdInline article slot

USB power flickers and cuts out. Suspected voltage sag from BLE/UWB ruled out. Culprit: faulty USB-A receptacle — full plug insertion loses contact, pulling it out half a millimeter makes it work. Takeaway: stick to quality cables and connectors.

SWD link drops over 90 cm cable through slip-ring in the turret. Packets fail to pass. A short 12 cm cable works fine. Ended up programming boards with flying leads.

Pin Conflicts and Debugging

JTAG/SWD fails to launch: 'No device found'. Firmware batch script demands manual reset via STM32 ST-LINK Utility. Cause: LED on PA13 (TMS/SWDIO). SWD pins (PA13, PA14) can't be used for GPIO. Relocating LED to PA15 restored debugging.

Google AdInline article slot

Board with FC7300: J-Link shows orange (reset state), J-Flash reports 'Could not download file'. MCU reflow didn't help. Temporary fix: swap USB port or programmer.

MCU Configuration and Bootloaders

CC26x2 hangs after power-cycle, even though it works under debugger. Cause: no write to customer configuration sector on the last Flash page. For TI CC26x4, first flash blinky_backdoor_select_btn26x2.bin using SmartFR Flash Programmer 2, then your own firmware.

STM32F413ZGJ6 bootloader fails to jump to app: MSP check in vector table >128 kB. MCU has 320 kB RAM, but bootloader was built for STM32F205VC. Cortex-M4/M3 compatibility masked the bug for five years.

Google AdInline article slot

Static Electricity and Reliability

Week-long test: logs in RAM get wiped by ESD spark on touch. Solution: NVRAM or SD card for logs.

Audio and Peripherals

I2S from BT1026 (Bluetooth Classic): raspy voice on nRF5340. WS at 50 kHz, but FSC-BT1026C module outputs samples only up to 48 kHz — zeros cause the rasp. Fix: BT1026 as I2S master.

Circuit Design Blunders

Forgot to power the MCU — a scrap wire fixed it. Or Ethernet PHY crystal at 23 MHz instead of 25 MHz: auto-negotiation fails. Olimex-STM32-H407: UART garbage due to 12 MHz crystal instead of 25 MHz in firmware.

SPI-NAND W25M02GV prototype: side pins short the thermal pad on perfboard. Reflow onto green PCB fixed it.

VNQ7E100AJ high-side driver: false current reading on open-load (V_SENSEH pull-up). ADC interprets it as overload. Chip swap in ECU revision.

FPU and Library Errors

snprintf() on Cortex-M33 crashes into Default Handler due to FPU issues during float formatting.

Key Takeaways

  • Check SWD/JTAG pins before assigning them as GPIO.
  • Configure TI MCU customer sectors before flashing custom firmware.
  • Use ESD protection and NVRAM for logs.
  • Validate crystals and connectors on prototypes.
  • Read the datasheet: features like open-load detection prevent false triggers.

— Editorial Team

Advertisement 728x90

Read Next