Hi everybody! I 'm a novice and trying to find my path in this fog... :) Well i try to implement an interrupt driven square wave at 38.5kHz. I 'm trying to implement this using timer2 in normal mode (Arduino Duemilanove) and i'm stuck with my poor (???) maths! So i read in the datasheet for the ATmega328 (page 150) that there is nothing so special. I thought i would use this maths (steps to get the desired 38.5kHz):

Set the prescaler value to 256 (max possible) (is this correct??)

16 000 000 / 256 = 62 500 = 16 us (is this correct??)

38 500 / 16 = 2 406.25 (is this correct??)

Calculate TCNT2 value MAX(uint8) - 2 406 = ????? :-/ (255 - 2 406)???

Apparently i 'm doing something (very) wrong?! What?! Is the frequency i 'm targeting not achievable in Normal Mode???

Thanks in advance