Skip to main content
Associate III
May 16, 2025
Solved

PWM jitter

  • May 16, 2025
  • 5 replies
  • 994 views

Hello, 

 

I am currently in the midst of developing a super simple system to create a varying load. It's basically to resistors in series with a transistor in parallel of the second resistor. The transistor is driven by a PWM signal to bypass the second resistor and modify the load.

I've been trying the circuit with a function generator and it's working perfectly.

I now need to switch the PWM generation to a timer of a STM32. I have a nucleog474RE.

I used one of the example code available via cubeIDE (TIM_PWMOutput) and changed the frequency to match what i need (3.2kHz) but whenever I try and use my circuit with it, the signal generated by the nucleo is nowhere near clean and smooth, there is a huge jitter that basically renders my circuit useless (I need very high precision and stability).

 

Would any one have any idea why this is happening and what to do to correct it ?

 

Thanks for the answers ! 

Best answer by Mike_ST

The Nucleo G474 has an external XTAL please use it, hopefully it will improve accuracy,

configure Crystal/ceramic for HSE as follow:

Mike_ST_0-1747399989404.png

Select HSE as input for the PLL and enter 170 in HCLK:

Mike_ST_1-1747400076303.png

 

5 replies

EliazLBAuthor
Associate III
May 16, 2025

The jitter makes the frequency vary between 3.200kHz and 3.205kHz.

Mike_ST
Technical Moderator
May 16, 2025

Hello,

What clock are you using as source for the PLL ?

 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
EliazLBAuthor
Associate III
May 16, 2025

Not quite sure, I think the internal clock...

Here is a screenshot.

I'm very new to all this so I'm not always sure about what I'm doing.

Mike_ST
Mike_STBest answer
Technical Moderator
May 16, 2025

The Nucleo G474 has an external XTAL please use it, hopefully it will improve accuracy,

configure Crystal/ceramic for HSE as follow:

Mike_ST_0-1747399989404.png

Select HSE as input for the PLL and enter 170 in HCLK:

Mike_ST_1-1747400076303.png

 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
EliazLBAuthor
Associate III
May 16, 2025

I just changed it and it worked perfectly !

Thanks for the advice !