1
\$\begingroup\$

If I want use a watch crystal(32KHz) with the low frequency crystal oscillator of an ATmega328p, which pin should I connect the crystal to?

Should I connect the crystal to XTAL1,XTAL2 pins of ATmega328p, or should I connect the crystal to TOSC1,TOSC2** pins of ATmega328p?

\$\endgroup\$
0

2 Answers 2

1
\$\begingroup\$

The XTAL pins are also the TOSC pins, so you really don't have an option to go wrong here.

\$\endgroup\$
2
  • \$\begingroup\$ Are you saying that XTAL pins and TOSC pins are internally connected and i can connect the crystal to either XTAL pins or TOSC pins to use the LOW Frequency Crystal Oscillator \$\endgroup\$
    – Rahul.In
    Commented Apr 10, 2019 at 5:07
  • \$\begingroup\$ Just look at the MCU pins on datasheet. You will find that TOSC pins are same as XTAL pins. \$\endgroup\$
    – Justme
    Commented Apr 10, 2019 at 8:16
1
\$\begingroup\$

A 32.768 kHz crystal is a crystal and needs to be connected to the "Low-frequency crystal Oscillator" which is connected to the TOSC1 and TOSC2 pins.

Which are the same pins as the XTAL1 and XTAL2 pins!

Are you confused yet?

The function of these pins is defined by the settings defined by the clock selection fuses. These are discussed in section 6.2 of the datasheet.

So you might have to (re)program the "fuses" to allow the 32 kHz crystal to be used.

Also realize that at a 32 kHz clock the MCU will operate quite slowly.

If you want to make a clock using an MCU, consider a dedicated RTC (Real Time clock) module like the DS1307.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Also of note, you can dynamically change the clock settings in code when the MCU boots rather than burning fuses. If the MCU is being clocked externally at such a low speed, you will also likely have to add a -B 1024 option to AVRDUDE programming commands to change the communication bitrate. \$\endgroup\$ Commented Jan 23, 2020 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.