Ok, this is where I'm at:
From the datasheet: Timers 1,3,4 and 5 are 16-bit timers.
from Arduino wiring.c:
// set timer 3, 4, 5 prescale factor to 64
sbi(TCCR3B, CS31); sbi(TCCR3B, CS30);
sbi(TCCR4B, CS41); sbi(TCCR4B, CS40);
sbi(TCCR5B, CS51); sbi(TCCR5B, CS50);
// put timer 3, 4, 5 in 8-bit phase correct pwm mode
sbi(TCCR3A, WGM30);
sbi(TCCR4A, WGM40);
sbi(TCCR5A, WGM50);
I can find these values in the datasheet as well (table 17-2), so I think I understand what is being done. I only need to add
sbi(TCCR3A, WGM31);
sbi(TCCR4A, WGM41);
to set the Timers 3 and 4 in 10-Bit PWM mode. These timers work with the following pins:
from pins_arduino.c:
TIMER3B , // PE 4 ** 2 ** PWM2
TIMER3C , // PE 5 ** 3 ** PWM3
TIMER3A , // PE 3 ** 5 ** PWM5
TIMER4A , // PH 3 ** 6 ** PWM6
TIMER4B , // PH 4 ** 7 ** PWM7
TIMER4C , // PH 5 ** 8 ** PWM8
TIMER5C , // PL 5 ** 44 ** D44
TIMER5B , // PL 4 ** 45 ** D45
TIMER5A , // PL 3 ** 46 ** D46
Interestingly, pins 44,45 and 46 can apparently also be used for PWM on the Arduino Mega.
Is this correct? If so, it's much easier than I anticipated. Should be easy to add some functions to set the PWM resolution to the Arduino code.
Setting the PWM frequency should be similarly simple.. by setting CS32, CS31, CS30, CS42, CS41, CS40, etc. I'll play with this as well.
When I've figured it all out, I'll post some simple functions that should help other idiots like me without having to revert to the datasheet.