Crosstalk

STM32 Garbled Log Lines Debug

Symptom

A door logger prints numbered sample lines on its trace console, and an event line each time the door sensor pulses. Since the event lines were added, the log has broken lines: two lines run into one, digits go missing, and part of a line shows up twice.

Circuit

Block diagram: U2, a door sensor, pulses PA0 of U1, an STM32F4; inside U1 the handler EXTI0_IRQHandler runs per pulse and main prints samples, and everything printf prints leaves through ITM port 0 on PB3 SWO to TP1, a trace console

Pass condition

Every line is whole, sample N or event N. The samples run from sample 1 to sample 300 with none missing or repeated, and each pulse gives one event line, numbered from 1 in order. The core runs EXTI0_IRQHandler once for every pulse. Each test pulses the sensor a different number of times.

Expected log for the three pulse case: whole lines only, sample 1 to sample 300 in order, and event 1, event 2 and event 3 each on a line of its own somewhere after its pulse

Notes

The sensor pulses PA0 high for 0.2 ms, at least 1 ms apart, while your program runs. Leave the trace setup and _write as they are. Your program is built and run at -O0, then again at -O2. Both builds must pass.

Related challenges

Loading the interactive arena.