Skip to main content
Graduate
January 24, 2024
Solved

STM32F217 HSE and Timer Sync

  • January 24, 2024
  • 1 reply
  • 3181 views

I'm working with an STM32F217 and I have a few timer channels setup as sync clocks to regulators (around 1.5 MHz). I'm checking to make sure my sync lines are actually using HSE as a reference clock by looking at the phase drift between my external oscillator output and an STM32 timer output on an oscilloscope. With the amount of drift I'm seeing it doesn't seem like the timers are referencing HSE. I'm confused though because bits 3:2 of RCC_CFGR say I'm referencing my external oscillator as my system clock.

Here are the related register values:

RCC->PLLCFGR = 0x24403c18

RCC->CR = 0x30b6983

RCC->CFGR = 0x940a

    This topic has been closed for replies.
    Best answer by TDK

    > external oscillator output

    So you're feeding a clock signal into PH0 (in which case HSE_BYP should be set) or are you using a crystal?

    Could output HSE on MCO and verify it lines up with your expectations.

    1 reply

    TDKAnswer
    Super User
    January 24, 2024

    > external oscillator output

    So you're feeding a clock signal into PH0 (in which case HSE_BYP should be set) or are you using a crystal?

    Could output HSE on MCO and verify it lines up with your expectations.

    PCarn.1Author
    Graduate
    January 24, 2024

    I have a crystal and function generator that can be switched with a jumper, neither of them are synced with MCO. When I look at MCO I get a 16 MHz signal, which is what HSI is set to. 

    RCC->PLLCFGR = 0x24403c18

    RCC->CR = 0x30f6983

    RCC->CFGR = 0x940a

    Super User
    January 24, 2024

    Select HSE as the MCO1 output in RCC_CFGR. It's HSI by default. You can also look at SYSCLK on MCO2 to verify system clock is actually using HSE, although your registers suggest it is.

    Can also check the CSSF bit in RCC_CIR to see if an error on HSE was detected.

    Crystal and function generator on the same pin can be causing issues. Certainly seems like a clocking issue.