Usually you just use the PWM or the timer, but recently when I needed to do more complex stuff with timers(Zero board) I could see there are some things I really don't get:
1.Why Timer resolution matter ?
Timer resolution is how much it can count to before it overflow. So for example if you want to create a square wave, with a 48Mhz clock, if the resolution is 8bits, it counts to 255, and if its 16bits its 65,535, but why is this matter, when you can get the interrupt every tick(at 48Mhz), then you write a code that divided it by any number you like by incrementing an integer on the interrupt, then skip every 2 ticks is to divided it by 2, and every 4 is to divided it by 4, you can now go forever and have as many bits resolution you like?? (is it all about the fact that the processor do this calculation in the background, not spending time?)
- Why PWM timer pins matter ?
Why there must be a physical connection between a PWM signal generated by a timer, to pin on the chip? when you count, you can then output high/low at every pin you like, is there any different ?
- Why PWM channels matter ?
What are channels even means? what really matter is how many independent timers you have, if you have 3 then you can create 3 PWM pins. But if you have 1 timer and 6 channel PWM what is it matter ? the whole 6 would have the same frequency because you have 1 timer, isn't it ??
- Maybe I am wrong but if you want a 50% duty cycle, you can only set the timer counter in increments of 2, which means you can count : 2,4,6,8,10... but then you get such a bad resolution for the first frequencies, and all the good resolution is down there in the big numbers, so for example 48Mhz between counter 10 to 12 is going from 4.8Mhz to 3Mhz- and you can never get the middle frequencies . Is there a way to solve that ??
There something wrong with my conception of the PWM thing I think.