Specialist Supplier of Crystals & Frequency Control Componentssales@mecxtal.com.cn0755-26500570
MERLIN home / Rednote / System Validation and Replacement

Why did an STM32F407 timer speed up by exactly 2× with the same 8 MHz crystal?

A data-acquisition board changes its bus prescaler and its 1 ms interrupt becomes 0.5 ms. On the STM32F407, identify the timer’s APB bus and that bus’s prescaler. The reference manual specifies that with an APB prescaler of 1, the timer clock equals the peripheral bus clock. For other prescaler settings, the timer clock is twice that bus clock. Passing the bus frequency directly to timer initialization can introduce a factor-of-two error.

Trace the register settings to the update event

Consider TIM2 in up-counting, edge-aligned mode without a repetition counter. Suppose HCLK is 168 MHz and APB1 divides by four. The peripheral clock is 42 MHz, but the timer receives 84 MHz. Set PSC to 83 for one tick per microsecond. Set ARR to 999 for a 1 ms update period. For both registers, add one to the programmed value to obtain the actual divide ratio or count length. STM32 clock-tree options vary by series, so check the complete MCU part number first.

Read back the clock configuration, PSC, and ARR in a debugger. Bring out a measurable marker from the update callback or a hardware output. If the callback toggles the output once per update, two updates occur between consecutive rising edges. Account for this in the frequency conversion. Compare hardware output with a software marker to separate interrupt scheduling latency from clock calculations.

Record the external crystal, PLL settings, bus prescaler, and resulting timer clock in the change review. If APB is reconfigured later to reduce power, test periodic acquisition, timeouts, and outputs driven by the timer. Checking only the CPU frequency misses possible changes in peripheral timing. If an external device triggers acquisition, compare its trigger interval before and after the change.ST RM0090 reference manual

Send us a part number or your requirements

Brand, frequency, quantity and delivery target — a useful place to start.

WeChat

MERLIN · TIMING COMPONENTS

Scan with WeChat to contact Sales

Add our WeCom contacts from your usual WeChat app.

On desktop, scan with your phone. On mobile, save the QR image and select it from your album in WeChat Scan.