I am making something for pwm driven strings of leds, I am now testing with a simple led per port, so no power issues. The attiny (861a at the moment, but I will be using '85s and 84's as well at a later stage) will need to drive ~4 outputs, independently. That means I cannot use hardware pwm, also because the dedicated pins must already be used by other stuff.
The good news is: it already works :-) It's not that difficult to make a software pwm implementation using a timer ;-)
Now what is the problem: at pwm duty cycle 1/255, the led is still quite bright. I'd like to be able to dim it even further.
So I tried 16 bits and later 12 bits, but it won't work. Whatever I put inside the prescaler fields or the counter compare registers, it won't go fast enough, the leds only flash, they're not dimming.
My actual questions:
Is this something one can expect from an attiny running on 8 Mhz? I calculated that I should be able to get a 60 hz refresh using clock = 8 Mhz, prescaler = 1, counter compare = 2, step = 65536 (16 bits pwm): 8 mhz / 1 / 2 / 65536 = 61 Hz. Instead the led flashes. It won't go any faster, only slower if I increment either the prescaler or the counter compare by A LOT. Is this asking too much from an 8 Mhz device? I also tried using 12 bit pwm (4096 steps), but it doesn't make any difference!
Would there be some smart way to increase the pwm resolution in the lower values only, e.g. in the 0-32 duty cycle range, while keeping 8 bit pwm?
I am now using timer0, timer1 has a "high speed" feature; you can feed it 64 mhz from a pll instead. Would that help? I fear not myself... I can also have the whole mcu run on the pll (16 mhz), would that help? I think it would, but I think it wouldn't help enough for 16 or even 12 bit pwm...
Any other smart thoughts? ;-)