rolandvanroy
New Member
Hello,
Thanks for this great forum with many helpful posts!
I have a question about the pwmout command on 28x2 chip:
I'd like to use 4 independent pwm signals with same frequency. PWM frequency around 250Hz, and preferably the max 1024 duty resolution. (The PWM's drive rather slow hardware, hence the low frequency)
I set the 28x2 frequency at 4MHz, and use pwmout pwmdiv16, B.0, 254, 510 command to set B.0 pin at correct 245Hz with 50% duty, which works well.
Now I do this for B.5 / C.1 / C.2 as well:
(I added a pause inbetween so I can see what is happening to the pins with oscilloscope). Then the program does some pwmduty commands to check duty cycle variation.
What happens: during the init cycle, I see on the scope that B.0 starts with the correct :16 frequency, but after defining the next pwm B.5, the B.0 frequency will reset to the undivided frequency, and when setting C.1, the B.5 pin also goes back to undivided frequency. C.1 and C.2 use same timer, and they stay at the divided frequency. So I end up with 2 pwm's at 3.9kHz and 2 pwm's at 245Hz (where each duty indeed can be set independently)
Is there a way to get 4 pwm's, all with :16 (245Hz) frequency?
I'm using latest version 5.3.5 program editor.
Thanks for your help!
Roland
Thanks for this great forum with many helpful posts!
I have a question about the pwmout command on 28x2 chip:
I'd like to use 4 independent pwm signals with same frequency. PWM frequency around 250Hz, and preferably the max 1024 duty resolution. (The PWM's drive rather slow hardware, hence the low frequency)
I set the 28x2 frequency at 4MHz, and use pwmout pwmdiv16, B.0, 254, 510 command to set B.0 pin at correct 245Hz with 50% duty, which works well.
Now I do this for B.5 / C.1 / C.2 as well:
(I added a pause inbetween so I can see what is happening to the pins with oscilloscope). Then the program does some pwmduty commands to check duty cycle variation.
What happens: during the init cycle, I see on the scope that B.0 starts with the correct :16 frequency, but after defining the next pwm B.5, the B.0 frequency will reset to the undivided frequency, and when setting C.1, the B.5 pin also goes back to undivided frequency. C.1 and C.2 use same timer, and they stay at the divided frequency. So I end up with 2 pwm's at 3.9kHz and 2 pwm's at 245Hz (where each duty indeed can be set independently)
Is there a way to get 4 pwm's, all with :16 (245Hz) frequency?
I'm using latest version 5.3.5 program editor.
Thanks for your help!
Roland
Code:
init:
setfreq m4
pwmout pwmdiv16, B.0, 254, 510
pause 1000
pwmout pwmdiv16, B.5, 254, 510
pause 1000
pwmout pwmdiv16, C.1, 254, 510
pause 1000
pwmout pwmdiv16, C.2, 254, 510
pause 1000
main:
pwmduty B.0,10
pwmduty B.5,20
pwmduty C.1,30
pwmduty C.2,40
pause 1000
pwmduty B.0,810
pwmduty B.5,820
pwmduty C.1,830
pwmduty C.2,840
pause 1000
goto main
Last edited: