Skip to main content
December 22, 2025
Solved

GPIO output pulse stability (bis)

  • December 22, 2025
  • 4 replies
  • 116 views

Hello,

Trying to do precise GPIO pulses with assembly code - on any STM Nucleo board - shows jitter and fluctuating frequency. I was told by a super user to do it via PWM

I would like to add some comment that may be interesting for others :

- trying to do precise pulses with PWM on the Nucleo H723 for example, still shows jitter and fluctuating frequency around the desire value. Same using HSE or HSI. Same with Nucleo-F411. Same with Nucleo-N667. I understand the reasons now.

But playing around the Nucleo-N657, I got some success : if you feed your CPU_clock directly with HSE (48MHz on board), and feed the other peripherals, including timer_clock with HSE+PLL (400MHz for example), then the resulting PWM is quite accurate and stable !

Regards,

    This topic has been closed for replies.
    Best answer by AScha.3

    So for your "PWM is stable" just look at the jitter of the source:

    - (good) crystals / oscillators can have very low jitter levels

    - RC or ring oscillators are "bad" , lot of jitter

    - using PLL ...depends on jitter of source (crystal ?) and the PLL setting and the "quality" of the design

     

    For lowest jitter have a separate oscillator (not on-chip) and decoupled supply for it.

    And for PLL , use it as the source,  if need PLL for higher frequency.

    And if using PLL for higher frequency, try different settings, to find the best setting.

    see ds also, about the jitter to expect from the PLL : here for H7Sxx

    AScha3_0-1766430376362.png

    or for F411 ...little bit worse :

    AScha3_0-1766431547131.png

     

     

     

    and see the jitter of a low noise oscillator (i use it for my audio player): AS318 b 

    AScha3_1-1766430568487.png

     

     

    4 replies

    Super User
    December 22, 2025

    You're referring to this thread: GPIO output pulse stability - yes?

    December 22, 2025

    Yes Andrew, I'm refering to my previous post : GPIO output pulse stability

    Super User
    December 22, 2025

    The reason this is happening is that "HSE Bypass" is driven from the incoming clock signal. On the NUCLEO-H723ZG this is an 8 MHz signal driven by the HSE within the ST-LINK. So it will have the same jitter as HSI.

    The user manual goes into some detail about this.

    TDK_0-1766421092530.png

     

    This is in contrast to the NUCLEO-N657X0-Q where the default HSE is the onboard crystal. Again, the user manual covers this:

    TDK_1-1766421153976.png

     

    Graduate
    December 22, 2025

    Hard to believe really. Double check the clock configuration of your project. The PWM output frequency stability & jitter should be and ARE exactly the same as MCU clock input parameters. On most of Nucleo boards (excluding STM32L series ones) it is possible (but not obligatory) to use 8 MHz clock from ST-Link (8.33 MHz option is available but not default on Nucleos with ST-Link 3). On newer ones (C0, H5, ...) onboard HSE oscillator or generator is included.

    If you use HSE as input clock, the only jitter and instability you may encounter originates from PLL and should be neglectable & hard to measure.

    @TDK: AFAIK, ST-Link output clock is generated by its crystal-driven HSE, so it should be pretty good.

    Super User
    December 22, 2025

    > AFAIK, ST-Link output clock is generated by its crystal-driven HSE, so it should be pretty good.

    @gbm On ST-Link V2 chips where the st-link uses a 8 MHz crystal, you would be correct. On the STLINK-V3E (which the NUCLEO-H723ZG has), the ST-Link chip uses a 25 MHz crystal and can't do this. There are a variety of outputs, but the default (8 MHz) is derived from the HSI.

    TDK_0-1766423469663.png

    Overview of ST-LINK derivatives - Technical note

    December 22, 2025

    Thanks for your comments, and I know the different clock sources for the various boards (as said in manuals)

    All the boards I've tested which have HSI or "derived" HSE (= coming from the STLINK quartz) make noisy PWM.

    All the boards I've tested which use "true" HSE (= quartz on board for CPU), but from which clock_CPU and clock_timer come from PLLs make also noisy PWM.

    On the N657, you can get the clock_CPU directly from the quartz (=48MHz), and the clock_timer from the PLL (=up to 400MHz). In this configuration, the PWM is stable.

    Regards,

    AScha.3Answer
    Super User
    December 22, 2025

    So for your "PWM is stable" just look at the jitter of the source:

    - (good) crystals / oscillators can have very low jitter levels

    - RC or ring oscillators are "bad" , lot of jitter

    - using PLL ...depends on jitter of source (crystal ?) and the PLL setting and the "quality" of the design

     

    For lowest jitter have a separate oscillator (not on-chip) and decoupled supply for it.

    And for PLL , use it as the source,  if need PLL for higher frequency.

    And if using PLL for higher frequency, try different settings, to find the best setting.

    see ds also, about the jitter to expect from the PLL : here for H7Sxx

    AScha3_0-1766430376362.png

    or for F411 ...little bit worse :

    AScha3_0-1766431547131.png

     

     

     

    and see the jitter of a low noise oscillator (i use it for my audio player): AS318 b 

    AScha3_1-1766430568487.png