OnlineCourse/SoftPwm

The AtMega128 has 4 timers. Each timers can generate PWM signals with the OCR (output compare) registers. The 16 bit timers (TMR1 and TMR3) have 3 OCR (sometimes called HW-PWM) channels, while the 8 bit timers (TMR0 and TMR2) have 1 OCR each. Unofortunately the output pin where OCR2's signal can be routed is conflicting (sharing the pin) with OC1C's pin, so only max 7 HW-PWM signals can be maintained.

There is a restriction: on the same TMR all the PWM signals run from the same timer, just the compare register is different, so the frequency must be the same (well, not necessarily, if some of the signals are 50%).

Sometimes we need more channels, and have slow devices like heaters, or whatever, that can easily be driven from software. There are 2 common ways to make PWM signal from software:

See softpwm.c in the firmware (see OnlineCourse/GettingStarted ).