cancel
Showing results for 
Search instead for 
Did you mean: 

PWM Frequency generated

Jess32
Associate II

Hi,

i am working on STM32F302R8Tx and i would like to have a  490 Hz PWM on Timer15 Channel2, 

attached are my configuration and my code, when i measure it , i become 491,13..Hz. what can I do to get the exact 490Hz? 

Any  Suggestions?? 

thank you!!!

Jess32_0-1704784722767.png

Clockkonfiguration.PNG

Pinout Konfiguration.PNG

 

 

 

 

 

 

3 REPLIES 3
AScha.3
Chief III

Hi,

you clock at 64MHz , 

so -> 64M / 130 = 492,3kHz

divide by counter (arr) : (1005-1) -> 489,9Hz (closest you can get here)

---

If you set 64M / 131  , arr (997-1) , then 490,02 Hz is possible.

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

Also, HSI is not a precise primary clock source (see datasheet for HSI specification), so there will always be some error introduced by that fact.

JW

Jess32
Associate II

okay, thank you for your answers!!!!!