Do not turn off an external bypass oscillator before requesting a normal HSE shutdown. ST's RM0091 says that once HSE is running, six more HSE clock pulses are required to complete the off sequence. If OSC_IN no longer toggles, the sequence may not finish, leaving oscillator pins unavailable for other use and causing unnecessary current consumption. ST recommends using the clock security system so the oscillator can also be disabled when the input disappears unexpectedly. This is a planned shutdown order, not merely the familiar problem of a processor falling back to an internal clock.
First migrate the system and dependent peripherals to their approved clocks and verify that they actually changed. While the external oscillator still runs, request HSE shutdown and observe the appropriate status. Only after completing that path should the board disable the source output or its supply. Six periods at 8 MHz equal 0.75 microseconds; this is a cycle-count conversion, not a guarantee for firmware-to-rail timing.
Use distinct validation cases for normal shutdown and unexpected input loss. Preserve OSC_IN, the source-control signal and HSE status on the same timeline. If an abnormal stop cannot be tested safely in the product, mark that scenario untested. Verify the exact oscillator enable option and electrical interface before promising the board can switch the clock off under firmware control.
Related selection guide: MERLIN Crystal Timing: Diagnosing STM32F407 Crystal Failure with CSS, NMI and Internal-RC Fallback Evidence
Resource link: https://www.mecxtal.com.cn/en/handbook/stm32f407-hse-css.html
