请大神帮忙用STC8G1K08A设计一下输出50hz三路循环PWM程序
本帖最后由 神不晓 于 2023-9-20 11:14 编辑第一路开10ms关10ms循环
第二路在第一路开启6.7ms之后开10ms关10ms循环
第三路在第一路开启13.4ms之后开10ms关10ms循环
感谢大神
The normal PWM channels all have a common zero, so you cannot use those.
The PCA does have a mode called High Speed pulse output mode, that toggles a pin on a match.
With 3 pins possible, you need to create a PCA interrupt, that writes 3 pairs of compares, one write for each edge on each pin.
You have 6 interrupts spread over 20ms,which is a light CPU load.
If your clock is a 2^16 multiple of 50Hz, the compare points will simply swap.
If the clock is not a 2^16 multiple, you can add (Sysclks in 10ms) to each compare interrupt, after setting the initial phase carefully 50Hz的PWM周期是20ms,做不到你要求的时间吧?比如开10ms管10ms,开半个PWM周期,我觉得没有啥意义。 梁工 发表于 2023-9-28 22:02
50Hz的PWM周期是20ms,做不到你要求的时间吧?比如开10ms管10ms,开半个PWM周期,我觉得没有啥意义。 ...
It is unusual numbers.
The only use case I could imagine, was some sort of 3 phase test/emulation? 梁工 发表于 2023-9-28 22:02
50Hz的PWM周期是20ms,做不到你要求的时间吧?比如开10ms管10ms,开半个PWM周期,我觉得没有啥意义。 ...
是的,试了下,第三路只能开33%的占空比,要不就没输出了,,,不知道用定时器能不能实现这个功能 神不晓 发表于 2023-9-30 12:51
是的,试了下,第三路只能开33%的占空比,要不就没输出了,,,不知道用定时器能不能实现这个功能 ...
将你要求的波形时序画出来,否则我没法明白你的要求。 梁工 发表于 2023-9-30 13:29
将你要求的波形时序画出来,否则我没法明白你的要求。
谢谢梁工,我自己弄好了,国庆节快乐
页:
[1]