2024-01-08 11:22 PM
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!!!
2024-01-09 12:14 AM - edited 2024-01-09 12:20 AM
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.
2024-01-09 01:17 AM - edited 2024-01-09 01:18 AM
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
2024-01-09 05:40 AM
okay, thank you for your answers!!!!!