PWM8 Question
steprog
Posts: 227
Hi Guys,
Im working with the PWM8 spin.· I'm was wondering is there a way to go faster than the 23000 that is given on the demo?
Thanks,
Greg
Im working with the PWM8 spin.· I'm was wondering is there a way to go faster than the 23000 that is given on the demo?
Thanks,
Greg
Comments
The maximum PWM frequency is the lesser of:
clkfreq / (13.5 * resolution) and 20.648881 / resolution MHz
The minimum PWM frequency is :
clkfreq / (40000 * resolution)
Thanks for the response,· I apparently made a mistake when I ran that calculation.· I get it now thanks.
Greg
I have been trying to figure out this code for the last couple of days. I hate to admit it but its way above my head. Im trying to feed PWM8 with an array of values from another code running assembly. Im trying to update the pwm at rates faster than 1khz. Except I haven't figured out what the data looks like in this code. Driving me nuts.
Anyone know this routine?
Thanks,
Greg
To update the PWM rates, you have to call duty for each channel separately. I doubt you will be able to achieve a 1KHz update rate for eight channels, though, since duty is written in Spin.
The pwmdata array that gets passed to the assembly cog consists of one byte per unit of resolution, plus one. Each byte represents a time slice in the state of all eight pins. A one bit in that byte means the pin will be high for that time slice; a zero, low. duty is written in such a way that the array is modified without causing glitches in the output. To modify that array more quickly, one would have to write an assembly version of duty (in yet another cog) that monitors an array of PWM values and modifes the pwmdata array in real time.
-Phil
Let me see if I got this right. Since I want to fix this at a given frequency and a fixed resolution, I should be able to simplify duty considerably. For instance, I have 8 bit resolution and the maximum frequency at 8 bits is 23k (not sure why, but so be it). If my data byte from an 8 bit adc is 0-256 what would the equivalent pwmdata look like? Could you give me an example?
Thanks,
Greg
How many PWM outputs do you need? (I was under the impression that you needed all eight. But now I'm not so sure.)
-Phil
Sorry for the late reply.· Out of town.· Yes using all 8 pwm's.·
Greg