An STM32F407 board stops logging but the debugger still connects. If it uses an 8 MHz passive crystal and the clock security system CSS is enabled, start with the non-maskable interrupt. CSS monitors the external high-speed clock HSE once it is running. If the system uses HSE directly or a PLL driven by HSE, failure causes a switch to the internal HSI. The processor may continue while a UART configured for the former PLL frequency can no longer transmit at the expected rate.
What to save before restarting
In the diagnostic firmware's non-maskable interrupt handler, read CSSF in the clock interrupt register and save the SWS system clock status. Store both values and an interrupt count in debugger-readable memory instead of relying on a UART whose clock may be wrong. After confirming CSS caused the interrupt, clear the pending condition with the documented CSSC bit. Otherwise repeated entry can make the program look completely stalled. Retain separate handling for other non-maskable interrupt sources.
If advanced timers drive PWM, check TIM1 and TIM8 break events and actual output states. A clock fault also reaches these timer break inputs, so motor outputs can stop while the microcontroller remains accessible to the debugger. On a prototype without an actuated load, compare a normal startup with a captured fault. Record the clock configuration before the fault, the source after switching and timer state before deciding how to reinitialize peripherals.
This diagnosis applies to an HSE that started and was monitored. If the board never sees readiness at power-on, log a startup timeout separately. Check whether the event occurred during startup or operation before replacing the crystal, since the two cases leave different evidence.ST RM0090, clock security system and RCC interrupt register
