consini 发表于 2023-6-29 15:23:57

PWM控制

请教一下大家使用的是STC8H系列的单片机,目前主频是12M

需要108.x KHZ的PWM输出进行扫频。问下输出pwm的小数点后面的可以精确更改吗?
例如:
108.1KHz,108.2KHz
有什么方法?

目前调试,输出的都不是很稳定。


consini 发表于 2023-6-29 15:25:03

大家有什么建议

jmg 发表于 2023-6-30 05:32:36

12M/108k = 111.1111111

So your choices near 108k, at 12MHz are only
114285.7143,113207.5472,112149.5327, 111111.1111,110091.7431,109090.9091,108108.1081,107142.8571,106194.6903,105263.1579,104347.8261 etc

You can improve that with a higher clock, but a lot higher needs a PLL, which some MCUs do have.

The data shows STC8H1K08T can drive PWM from PLL Clock of 144MHz
so with that you can get
108597.2851,108515.4484,108433.7349,108352.1445,108270.6767,108189.3313,108108.1081,108027.0068,107946.027,107865.1685,107784.4311,107703.8145,107623.3184,107542.9425



TheSTC32F12K54 has even faster PLL, > 250MHz PWM
https://www.stcaimcu.com/forum.php?mod=viewthread&tid=2729

consini 发表于 2023-6-30 08:58:27

jmg 发表于 2023-6-30 05:32
12M/108k = 111.1111111

So your choices near 108k, at 12MHz are only


OK ,thank you!
页: [1]
查看完整版本: PWM控制