cancel
Showing results for 
Search instead for 
Did you mean: 

Hello ST community, I am a new member! I would like to ask how does the PWM generation in advanced timers work.

Hajer_GAMMOUDI
Associate II

In my case I configured my counter as center aligned mode and my PWM mode as PWM mode 1.

Finally I used the CCR(compare capture register) but i don't have no idea how this CCR work that means it sends a PWM signal every period of time or point by point.

Thank you for your answer.

1 ACCEPTED SOLUTION

Accepted Solutions

PWM is typically sent in a block-by-block. You configure the timer module with the desired parameters, such as the PWM frequency, duty cycle, and the hardware takes care of generating the PWM waveform based on these settings.

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

6 REPLIES 6
Foued_KH
ST Employee

Hello @Hajer GAMMOUDI​ ,

In PWM mode, the frequency determined by the value of the TIMx_ARR register and TIMx_CCRx

The signal can be generated with a duty cycle determined by the register value. The value set in the CCR decides the width of the pulse.

Assign a value of 0-65535 to this register directly to determine the duty cycle. Duty cycle calculation method:

the value of TIMx_CCRx divided by the value of the ARR register is the duty cycle because the duty cycle is between 0 and 100%, the value of the TIMx_CCRx register generally cannot exceed the value of the ARR register, otherwise it may cause PWM The accuracy of the frequency or duty cycle.

Read the TIM chapter in RM for more details.

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Danish1
Lead II

As @Hajer GAMMOUDI​ says he is new to the ST world, it might be helpful to point out that RM in @KHALSI_Foued​ ‘s reply refers to the Reference Manual. Each group of Stm32 microcontrollers has its own Reference Manual and they describe in detail how every ST peripheral works right down to which bit in which register needs to be set for each function.

I’ll admit that the Reference Manual is not an easy read at times, but that’s only because it is complete and the peripherals being described are very powerful and flexible.

There is also the Programming Manual which describes the Arm processor and those peripherals designed by the Arm company. But that’s not relevant for timers.

Thank you @KHALSI_Foued​, but my question was if the PWM signal is sent every period of time or point by point, that means is it generated by blocks or point by point.

PWM is typically sent in a block-by-block. You configure the timer module with the desired parameters, such as the PWM frequency, duty cycle, and the hardware takes care of generating the PWM waveform based on these settings.

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Thank you very much!

If this solves your problem, please mark my answer as "Best Answer" by clicking on the "Select as Best" button, this can be helpful for Community users to find this solution faster. 

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.