Possible to control PWM frequency and duty?

I have a bit of AVR experience but I was just wondering if anyone a bit more experienced could give me a bit of advice on the feasibility of getting this working before I start out.

I've got a project where I need to be able to vary PWM frequency AND duty cycle at the same time. The PWM range needs to be say from 1kHz up to 20kHz and my duty cycle needs to be able to go from say 10% ON to 100% (fully ON). In at least say 10% increments in between.

I know the toneAC library is pretty close to what I want, I'm just not sure it has the duty cycle control I need. (I have a feeling the duty cycle only goes from say 0% to 50% whereas I need up to 100%).

If anyone can give me any hints on whether this is doable? Which timers to use? Will I have to use the 16bit timer? PWM modes?

Thanks heaps.

This simple wav demo sets the frequency and varies the duty cycle. It would be easy to adapt it to change the frequency also.

This uses Timer2 but the same principles apply to all the timers.

Changing the frequency over a wide range will involve a good deal of juggling of registers. You will need to study the Atmel datasheet carefully.

...R

You could check out the "PWM Frequency Library". I've used it, but haven't tried changing the frequency on-the-fly.
I think it should be possible, though.
It supports frequencies from 31Hz to 2MHz on 8-bit timers, and 1Hz to 2MHz on 16-bit timers.

The thread on the subject:-
PWM Frequency Library thread

And the library:-
PWM Frequency Library download