PWM for Audio x Max Frequencies ?

Ok, I'm trying to understand the math behind how PWM work in terms of max frequency noise it can generate.

For instance, if I use a regular 8-bit timer and want Fast PWM output for Audio, what's the lower frequency it will generate by itself, so I can filter it. This way, I know the max sample-rate I can get. I'm also thinking on running the ATmega328 at 20Mhz, to get better audio output.

I'm trying to understand the math behind PWM, but so far the sites I found don't match the datasheet. For instance, this site below, tells me PWM frequency, with no scaler, is 62k for the 16 bit Timer but 31K for the 8 bit timer. While the datasheet shows that the 8 bit timer is actually CLOCK / 256 which would be 62k, not 31k. Hummm.... what gives? Did I read the datasheet badly?

http://www.arduino.cc/playground/Main/TimerPWMCheatsheet

Also, if the PWM frequency is 62k, does this means that the lowest frequency will be 62k or what? This way I would know that the lowest audible sound would be 62k, which no speaker can reproduce.

Just trying to understand the whole thing. Thanks for any input. 8)

Best Regards, WilliamK

Ahh, the link above seems to be using regular PWM, not Fast PWM Mode, that's why I got confused. 8)

Here's another interesting arduino page about PWM x PCM sound.

http://www.arduino.cc/playground/Code/PCMAudio

Ok, here's some math, ATmega328 at 20 Mhz using Timer2. This is from the Datasheet, Fast PWM Mode.

Clock / 256 = 20000000 / 256 = 78125

Now, what does that means in terms of audio noise the PWM will output. Is 78125 the lowest frequency I can expect, so filtering anything below 40k will be ok? I need to know this, I could test, of course, which I think I will, just in case. ;-)

I'm thinking on getting a sample-rate of /2 that, which would be 39062 samples per second, not bad. I could have the Timer overflow interrupt called and just check to handle the next sample every 2 times it happens.

Well, just brainstorming out loud. 8)

Best Regards, WilliamK