2024-08-04 01:10 PM - edited 2024-08-04 01:11 PM
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 :)
Solved! Go to Solution.
2024-08-05 06:38 AM
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:
Implement Frequency Modulation:
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:
Implement Duty Cycle Modulation:
2024-08-04 02:45 PM
Check out in Reference Manual for this uCPU if it's Timers support dithering mode.
2024-08-04 04:57 PM - edited 2024-08-04 04:57 PM
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
2024-08-04 06:40 PM
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.
2024-08-05 06:38 AM
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:
Implement Frequency Modulation:
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:
Implement Duty Cycle Modulation:
2024-08-06 10:46 AM
I come across App. Note AN4507, check it out:
https://www.st.com/en/embedded-software/x-cube-pwm-dithr.html
2024-08-07 05:20 AM
Thank you @MasterT