SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
By fsphil
Evening all!

I've noticed an odd thing my AVR Tiny2313. I'm using all four PWM channels to drive some LEDs - real simple stuff - but for some reason I can't get a duty cycle of 0x00 for the channels driven by Timer0. The LEDs are still lit (less than duty at 0x01, but not off). The other two PWMs (which I have configured as 8-bit) don't show this problem.

I can turn the PWM off manually when the duty == 0x00, but I'd like to know why I have to.

Any ideas?
By mkissin
IIRC, there is a PWM mode on the AVRs that ends up with you having to choose between being able to achieve a PWM of 100% or 0%, but it can't do both. Something along the lines of the compare unit being "less than" or "less than or equal to".

I might be thinking of another chip though.
By fsphil
No, I think your right. Found this in the data sh**t: (this word is censored?)
The extreme values for the OCR0A Register represents special cases when generating a PWM waveform output in the fast PWM mode. If the OCR0A is set equal to BOTTOM, the output will be a narrow spike for each MAX+1 timer clock cycle.
Although it says the same for Timer1's fast PWM mode, an effect I'm not seeing.
By fsphil
fsphil wrote:Although it says the same for Timer1's fast PWM mode, an effect I'm not seeing.
... which was because I had it configured for Phase Correct mode, not Fast PWM.

By fsphil
Ok, I take that back. Even configured to use fast PWM Timer1 turns off completely when the duty == 0x00.
Anyway - I understand the problem with Timer0 and how to deal with it now and that was the main problem.