# Using UART clock 3.6864 Mhz for a microcontroller

I want to use a 3.6864 MHz external oscillator to clock my ATMEGA328p to ensure 'error free' serial communication. When I looked at this page, I see that 3.68464MHz is also represented as 2*1.8432 MHZ.I'm at a loss as to what this means. Does this mean that I'd have to use two 1.8432 MHZ clocks to somehow generate 3.6864 MHz? Or does it just show me how this value (3.6864 MHz) came to be? If the former is true, how CAN I generate 3.6864MHz with two oscillators at a lower frequency? Are oscillators available at these 'multiple' rates of 1.8432MHz?

Will this communication will truly be error free as the page linked claims?

How would I connect the oscillator to the microcontroller? The datasheet confused me a bit because section 8.4 makes it seem that I place the oscillator between XTAL1 and XTAL2, while 8.8 suggests that I connect it to XTAL2 with XTAL1 not connected. So there's some confusion there, though 'm inclined to think that the latter is what I'm looking for. But, how can I connect the two pins of an oscillator to just the XTAL1 pin?

• I want to use a 3.6864 MHz external oscillator Do you mean a two pin crystal ? If so you follow what is shown in section 8.2 including two external capacitors – alexan_e Dec 26 '13 at 16:45
• Section 8.4 talks about crystal oscillator, whose leads must be connected to XTAL1 and XTAL2 respectively (plus the appropriate capacitors), while section 8.8 talks about an external clock source, which contains a crystal oscillator, capacitors and all circuitry needed to generate such clock. I came across an answer today explaining the differences between the two. – Ricardo Dec 26 '13 at 16:50
• UART-based serial communications that use a 16x clock can tolerate relatively large variations in crystal frequency without causing error. A frequency that is within 1% of ideal is just as good as your exact frequency and pretty easy to achieve if you start with a higher crystal frequency. – Joe Hass Dec 27 '13 at 4:02
• No, in this kind of communication the receiver resynchronizes with the transmitter at the beginning of every byte. The receiver looks for the falling edge of each start bit and uses that as a reference point. The receiver then samples each bit in the middle of the expected bit duration. So, the accumulated timing error can be almost half of a bit time when the stop bit comes and the communication still succeeds. – Joe Hass Dec 27 '13 at 12:05
• The only situation where you need to be concerned about picking the right crystal frequency is when the microcontroller has a low clock frequency but you want to operate the serial communications at a high baud rate. You need to be able to divide the crystal frequency down to 16X the baud rate with an difference of less than about 2% with respect to the ideal baud rate. – Joe Hass Dec 27 '13 at 12:11

The datasheet confused me a bit because section 8.4 makes it seem that I place the oscillator between XTAL1 and XTAL2, while 8.8 suggests that I connect it to XTAL2 with XTAL1 not connected`

The microcontroller has several clocking source options (internal or external).
One of them is by connecting an external crystal to XTAL1 - XTAL2 (section 8.2)

Another clock source can be using an external oscillator (this means an external device that generates the clock pulses) which can be used like

You can use one or the other, not both of them.

Regarding your question about the UART you should check section 19.11 which has several tables showing the error percentage for a given baud rated and crystal frequency used.

For your specific case with a crystal of 3.6864 MHz the table that shows the possible baud rates and the error percentage is

and it's perfectly usable with 0 % error in all the common boud rates.

• To be sure, I'll be using a crystal of 3.6864 MHz and not 2 crystals of half the frequency, right? It sounds ridiculous, I know, but the way the site I linked represented that clock gave me a fair share of doubt. – Analon Dec 26 '13 at 16:52
• @Analon Yes, you only need to use a single crystal connected to XTAL1-XTAL2 and the appropriate capacitors. – alexan_e Dec 26 '13 at 17:16
• Please note that the 0% error refers only to the error in dividing the master clock frequency to create a baud rate clock. This table is not referring to errors in data transmission and reception. "Error free communication" depends on many other factors. – Joe Hass Dec 27 '13 at 3:58