Timer frequency documentation disagree?

Hello

I have been reading Arduino Playground - HomePage which talks about adjusting PWM frequencies, and which tells us that...

Pins 11 and 3: controlled by timer 2

Setting Divisor Frequency
0x01 1 31250 -- particularly this line...
0x02 8 3906.25
0x03 32 976.5625
0x04 64 488.28125

But, I compare this with another page http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM which, talking about a particular example, contains the paragraph...

The output frequency is the 16MHz system clock frequency, divided by the prescaler value (64), divided by the 256 cycles it takes for the timer to wrap around. Note that fast PWM holds the output high one cycle longer than the compare register value.

These two sources seem to disagree. Assuming the prescaler was 'switched off' (i.e. 0x01 "divide by one", like the top line of the table, above), I make the result of the expression system_clock_freq / prescaler / cycles_for_timer_wrap_around ...

16000000 / 1 / 256 = 62500

... exactly double the figure given in the table in the TimerPWMCheatSheet.

Is the document wrong? Probably not!! What have I misunderstood.

thanks all

Sam

Hmm...confusing...

There is an old topic, according to post #12 Timer2 is running phase correct PWM, which would explain difference in math. Timer0 running in different mode, Fast PWM and so twice faster.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235060559

timer0 runs in fast-mode, cycles every 2^8 = 256 (prescaled) clocks.

timer1 and timer2 run in phase-correct mode, cycles every 2*(2^8-1) = 510 (prescaled) clocks. 16MHz/510 = 31372Hz (not 31250)

(timer1 is 16 bit but by default is run in 8-bit mode)

Note the prescaler codes are not identical for all 3 timers, which is a real "gotcha" if you don't realise.

Thanks all. That explains it!