Counter PWM with no jitter?
Dave Matthews
Posts: 93
I need to output a signal that will span from 1.0 to 1kHz that will have a duty cycle span of 1 to 99%. I thought I could do that with the Counters, but I had less than good results. Perhaps it is my bad coding or perhaps it is because "for values of FRQA which are not a power of 2, there will be jitter present on the output signal since the most significant bit of PHSA will toggle at an inconstant rate". (Propeller application note AN001, page 17.)
I tried a few examples in the OBEX for counter use to provide such PWM with duty cycle control, but they all had jitter. The spin examples work fine.
Am I correct in my conclusion that using counters exclusively will not give me a jitter free signal for my needs?
Dave
I tried a few examples in the OBEX for counter use to provide such PWM with duty cycle control, but they all had jitter. The spin examples work fine.
Am I correct in my conclusion that using counters exclusively will not give me a jitter free signal for my needs?
Dave
Comments
That's probably easier with just WAITCNT.
There will be a SW limit on how short one can be, but 1kHz 1% is 10us, which will be fine in PASM.
With On/Off time loading there should be no jitter between cycles, and the granularity will be small at 1Hz~1kHz
(I think ~12 MilliHertz)
I'm with jmg: do it in software with PASM.
-Phil
Duane J
I think I've tested the 8 channel 8-bit PWM module in my Tachyon to 5kHz, It's table based so a 256 byte table holds the pattern for 8 channels.
At such low frequencies you can do it all in Spin:
Andy
A benefit of this approach, is a second (same freq) PWM comes almost for free by using the 2nd counter.
I can't see a way to avoid a small phase shift on the two though ?
Andy
Dave
Dave