PWM frequency library

8 bit timers are 'capable' of 8 bit resolution, 16 bit timers are 'capable' of 16 bit resolution. For the sake of consistency, I stuck with 8 in this library. It didn't occur to me that there was any need to bump up the resolution. I will happy to add some methods when I get some time to do so within a few days. It should be noted, however, that this would only affect 16 bit timers.

Note: there is also one caveat you must associate with AVR timers and resolution. The resolution effectively decreases inversely with the frequency. At 1KHz you get ~13 bits of resolution. At 100 KHz, you get ~6 bits of resolution. At 1 MHz you get ~3 bits of resolution. This is a property of the timers on AVR CPUs and cannot be changed by software.

To check your resolution at a given frequency, set the frequency on the timer of your choice. The SetFrequency functions are aware of all of the variables, and will mathematically determine the method of creating the highest possible resolution. Then call TimerX_GetTop() and add 1. That will be your resolution in base 10 (decimal). Take Log base 2 of that and you can get your resolution in binary. In other words:
Resolution = LOG2(TimerX_GetTop() + 1).

Just out of curiosity; what do you need the resolution for, and what board are you using.

Edit: forgot the +1 in the original post