Hardware PWM with Timer_A0
Up mode with OUTMOD_7 (reset/set): the output resets on the CCR1 match and sets when the timer wraps at CCR0. CCR0 fixes the period and CCR1 the duty cycle. There is no interrupt at all: the waveform is generated purely by hardware.
What to watch as you step
- PWM period = CCR0 + 1; duty cycle = CCR1 / (CCR0 + 1)
- OUTMOD_7: reset at CCR1, set at CCR0
- Zero CPU load once configured; the main loop just idles
- Change DUTY and re-run to change the LED brightness