Good luck operating it at 6.58 bits
That's its maximum resolution at that PWM frequency. It's still a 10 bit pwm.
Good luck operating it at 6.58 bits
That's its maximum resolution at that PWM frequency. It's still a 10 bit pwm.
You've never used 6.58 bits? The trick is what to do with the little bit (1.42) left over all the time
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
I would try that but my 2.3 kids will eat them
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
It's not variable in the sense that you can change it, it changes as function, or relation, between the clock frequency and PWM frequency.but still, why does the datasheet, even the one for the 18F4550 'indicates' a variable bit resolution...
If you had a 1MHz clock (Fosc/4=1Mhz) and wanted a 1Mhz PWM frequency you'd get two different dutycycles, 0% and 100% -1 bit resolution (not very useful). If you lower the PWM frequency to 100kHz you'd have 10 different dutycycles available. How many bits does the value 10 occupy? Well, you can't fit it in 3 bits and 4 is more than you actually need. Using the formula in the datasheet tells us that it's 3.32 bits. Obviosuly there are no such thing as partial bits and you'd need 4 bits to actually be able to use all 10 dutycycles but writing anything "above" 10 to these four bits will result in a dutycycle of 100%.
Now, if the PWM module gives you a higher resolution than you want you can obviously "scale up" your low resolution value to fit whatever number of bits of resolution there is, as have been shown earlier.
/Henrik.
right...
So, if TMR6 is setup to feed the PWM's... and 'overflows' @ 80KHz...
If the PWM's were 8 bit then i'd expect a cycle frequency of 312.5Hz...
If the PWM's were 10bit then i'd expect a cycle frequency of 78.125Hz...
Where on earth are these stupid decimals coming from?
Who on earth made a PWM system so complicated?
and which idiot approved their design?
If the hardware is static 10bit... why the hell would the datasheet even suggest any other resolution? I don't even understand how you couldn't use 10bit resolution on hardware PWM...
I really don't understand how these PWMs work... They are backward and alien to me...
So, can someone please explain in English how to setup the PWMs (ie how the hell you get a different bit resolution)?
Thanks
Last edited by comwarrior; - 30th January 2011 at 21:56.
Look at the related registers... it's timer based, then look which feature are in Timer... YUP you got it... prescaller OSC/2,4,8,16... hence the decimals.
Use the PICMulticalc, set a low PWM frequency see the resolution... set it way higher... see the resolution.
Conclusion?
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
comwarrior,
Henrik and others are trying to help you understand. There is no need to get upset.
I am asking you to keep an eye on your language. This is a "family" type forum.
Dave
Always wear safety glasses while programming.
Bookmarks