cancel
Showing results for 
Search instead for 
Did you mean: 

How do I generate spread spectrum PWM?

Ricko
Senior II

Hi,

I am using a STM32L452RET6. How do I generate spread spectrum PWM on that particular micro?

I read somewhere it has a dedicated mode but did not find where.

Is there perhaps a library specifically for it?

If it does not have a dedicated mode or peripheral for spread-spectrum, how do I generate it in other ways using the standard PWM channels?

Thank you :)

1 ACCEPTED SOLUTION

Accepted Solutions
Saket_Om
ST Employee

Hollo @Ricko

 

The STM32L452RET6 does not have a dedicated mode or peripheral for generating spread spectrum PWM directly. However, you can achieve spread spectrum PWM using standard PWM channels by modulating the frequency or duty cycle of the PWM signal. Here are some methods to achieve this:

Method 1: Modulating the Frequency
You can modulate the frequency of the PWM signal by periodically changing the timer's auto-reload register (ARR) value. This will effectively spread the spectrum of the PWM signal.

Configure the Timer for PWM Output:

  • Set up a timer to generate a PWM signal on a specific channel.
  • Configure the timer's ARR and CCR (capture/compare register) values to set the initial frequency and duty cycle.

Implement Frequency Modulation:

  • Use a timer interrupt or a software loop to periodically change the ARR value.

Method 2: Modulating the Duty Cycle
You can also achieve spread spectrum by modulating the duty cycle of the PWM signal. This can be done by periodically changing the CCR value.

Configure the Timer for PWM Output:

  • Set up a timer to generate a PWM signal on a specific channel.
  • Configure the timer's ARR and CCR values to set the initial frequency and duty cycle.

Implement Duty Cycle Modulation:

  • Use a timer interrupt or a software loop to periodically change the CCR value.
If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

View solution in original post

6 REPLIES 6
MasterT
Lead

Check out in Reference Manual for this uCPU if it's Timers support dithering mode.

Thank you @MasterT, I didn't know it was also referred to as dithering.

It doesn't mention it anywhere so I assume it does not support it. How do I implement it in software? I didn't find any application notes, does anybody know of any?

Thank you

1. Define bandwidth, let say 10 % of PWM frequency. TIM->ARR = SystemFrequency / PWM_Freq.

2. Generate pseudo-random array of data in between TIM->ARR min = -5%, TIM->ARR max = +5%

3. Set DMA to update ARR on periodic base (there is app note and examples of code from ST).

Probably, it makes sense to update CCR register as well in the same way  (defines duty cycle) using DMA Burst mode, so it would keep CCR / ARR ratio constant.

 

Saket_Om
ST Employee

Hollo @Ricko

 

The STM32L452RET6 does not have a dedicated mode or peripheral for generating spread spectrum PWM directly. However, you can achieve spread spectrum PWM using standard PWM channels by modulating the frequency or duty cycle of the PWM signal. Here are some methods to achieve this:

Method 1: Modulating the Frequency
You can modulate the frequency of the PWM signal by periodically changing the timer's auto-reload register (ARR) value. This will effectively spread the spectrum of the PWM signal.

Configure the Timer for PWM Output:

  • Set up a timer to generate a PWM signal on a specific channel.
  • Configure the timer's ARR and CCR (capture/compare register) values to set the initial frequency and duty cycle.

Implement Frequency Modulation:

  • Use a timer interrupt or a software loop to periodically change the ARR value.

Method 2: Modulating the Duty Cycle
You can also achieve spread spectrum by modulating the duty cycle of the PWM signal. This can be done by periodically changing the CCR value.

Configure the Timer for PWM Output:

  • Set up a timer to generate a PWM signal on a specific channel.
  • Configure the timer's ARR and CCR values to set the initial frequency and duty cycle.

Implement Duty Cycle Modulation:

  • Use a timer interrupt or a software loop to periodically change the CCR value.
If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

I come across App. Note AN4507, check it out:

https://www.st.com/en/embedded-software/x-cube-pwm-dithr.html 

 

Thank you @MasterT