using counters to realise a "set and forget" variable dutycycle PWM-Signal
StefanL38
Posts: 2,292
Hi, counter-experts,
recently I was looking for democode to create a pwm-signal with variable duty-cycle.
(I mean High/Low-Ratio 0,01 to 0,99)
I only found code that were using the counters but still needs spin or pasm to keep things going.
This counter has 32 different operationmodes and there are two counters in each cog
Is there a way to setup the counter registers that the counters can create the pwm-signal at a fixed frequency but with
variable duty-cycle? Yes there is (see above)
BUT! Is there a way that the two counters per cog work together to create that signal without any code that sets up counter-registers
periodically? I mean "set and forget"
I did dive not very deep into programming the counters. But I guess if two counters interact it should be possible to realise that?
or not?
best regards
Stefan
recently I was looking for democode to create a pwm-signal with variable duty-cycle.
(I mean High/Low-Ratio 0,01 to 0,99)
I only found code that were using the counters but still needs spin or pasm to keep things going.
This counter has 32 different operationmodes and there are two counters in each cog
Is there a way to setup the counter registers that the counters can create the pwm-signal at a fixed frequency but with
variable duty-cycle? Yes there is (see above)
BUT! Is there a way that the two counters per cog work together to create that signal without any code that sets up counter-registers
periodically? I mean "set and forget"
I did dive not very deep into programming the counters. But I guess if two counters interact it should be possible to realise that?
or not?
best regards
Stefan
Comments
The two interacting counter method does require an external gate but why aren't you considering using a cog for this, I mean the Prop has eight cogs for this very reason, so that they can become peripherals. No point in having them run idel.
I have an 8-bit PWM that runs up to 7.6kHz and up to 32 channels from the one cog. If you are not using all the cogs then surely this is the logical course.
Hi Peter,
thank you very much for your quick answer.
Peter: the object kuroneko posted has a variant that "does exactly that " using a cog.
best regards
Stefan