PWM with TIMER0 (8 bit)
ATmega328P.pdf ( Register summary on p 428 )
PWM with TIMER0, simplified block diagram.
8-bit TIMER0 and TIMER2 can each generate two PWM-signals (pin OC0A OC0B OC2A OC2B). 16-bit TIMER1 can also geneate two PWM-signals (pin OC1A OC1B). Sample program below generates a PWM signal (OC0A) with a fixed duty cycle value. Can be used for a "stepup converter".
The full program is available here:
tmr0pwm.txt
(for Arduino use code stored as: tmr0pwm\tmr0pwm.ino)AD-converter (A0/PC0) 8 most significant bits are copied to TIMER0 PWM (OC0A/PD6). Can be used as a "dimmer" for the LED.
The full program is available here:
ADtmr0pwm.txt
(for Arduino use code stored as: ADtmr0pwm\ADtmr0pwm.ino)
William Sandqvist william@kth.se