cancel
Showing results for 
Search instead for 
Did you mean: 

Frequency PWM calculation vs real

ELECL.2
Associate II

Hi, 

I would like to understand why I don't have the right frequency on my PWM. I am working on STM32F103RG.

I would like to have a 8Khz PWM on Timer 3 channel 1, so I have configure my HSI to 8Mhz. APB2 Timer is set to 8Mhz. Prescaler to 10 and ARR to 100. 

So theoretically, my frequency PWM is 8Mhz, but when I measure it, I have 7.22khz. Around 10% from 8Khz. And HSI can have around 2% tolerance so this not the problem...

Some one have this problem ? Why I can't be able to have 8Khz ? 

 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

You're off by one. Set PSC=9 and ARR=99.

8 MHz / (10 + 1) / (100 + 1) = 7.2 kHz

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Guru

You're off by one. Set PSC=9 and ARR=99.

8 MHz / (10 + 1) / (100 + 1) = 7.2 kHz

If you feel a post has answered your question, please click "Accept as Solution".

Thanks ! Need to read datasheet careful with PSC bit !