32.768khz from Arduino UNO

Hi guys,

I have an Arduino UNO and i want to generate a signal of 32.768 khz on pin 9 to drive a sensor.

Please Help

It won't be very accurate compared to a 32KHz crystal.

Tell me how.

http://playground.arduino.cc/Code/Timer1

?

I think, it is unable to derive exactly 32768 from the system clock. There is 1, 8, 16MHz or 128kHz available, none of them with integer divisor to 32768. ATmega328P can be clocked by 32.768kHz crystal but the pins are the same as for main crystal. If you need just to generate 32768Hz signal the all you need is e.g. RTC based on DS3231 chip. The chip has programmable output with 32768Hz square signal by default just after power is applied to the chip.

The closest you could get is 32786 (prescaler of 4, TOP of 121). That wouldn't be too far off - but that's assuming the resonator is actually giving you 16Mhz - but it's only spec'ed to +/-2% I think, so that systematic inaccuracy is dwarfed by the inaccuracy of the resonator.

The reason a lot of us are expressing discomfort with generating the signal wit hthe Arduino is that normally 32768hz is used for precision timekeeping. You will not get good timekeeping using the Arduino to generate that frequency, it won't be very close to 32768 - not with a system clock source not integer divisible to 32768 nor with a rubbery resonator as that clock source.

mudassir9999: Tell me how.

... please?

mudassir9999: Tell me how.

First off, tell us what your "sensor" is.

// Per.

mudassir9999: Tell me how.

http://forum.arduino.cc/index.php?topic=210524.0 Use Google translate from French

Ray