Phantom
Works at -O0, Fails at -O2 Debug
Symptom
At -O0 the report reaches the terminal and PA5 pulses. At -O2, nothing arrives and PA5 never moves. This bench grades the -O2 build. The registers and bit fields are on the Datasheet tab.
Circuit
Pass condition
The bench sends one burst of pulses on PA0 while your program runs. The burst ends once PA0 has been quiet for 5 ms. Within 15 ms of its last pulse, USART1 sends COUNT:<n> then LEVEL:<band>, and PA5 pulses once.
Notes
Bands by count: 1 to 2 LOW, 3 to 5 MEDIUM, 6 and up HIGH. The build refuses optimization pragmas and attributes.