Archive for September 5th, 2010
The Arduino Mega has five hardware Timers, each with up to three PWM outputs. Most of the outputs go to headers, but the correspondence between Timer hardware and Arduino PWM number is not obvious.
Although the Mega schematic shows PWM0 and PWM1, they don’t really exist; they’re actually the serial I/O bits for the FT232 USB converter.
PWM4 uses Timer 0: OC0B. Don’t mess with Timer 0’s prescaler to get higher speeds; it’ll wreck the millis() function and the firmware’s timekeeping in general.
Timer 5 doesn’t come to a header. If you desperately need three more PWM outputs (that aren’t supported by the Arduino runtime), you could affix three fine wires to pins 38, 39, and 40 of that TQFP. Good luck with that…
Some notes about fiddling with the Arduino PWM setup: changing the frequency and going much faster. The new Timers have different numbers, but the same considerations apply. As before, Thou Shalt Not Mess with Timer 0!
Consult the Fine Manual for the ATmega1280 chip to get all the details.