How do I share a single crystal (not a complete oscillator module) between two micros? Is it OK to just connect everything as normal for the first micro and also directly connect its XO to the XI of the second microcontroller? I expect to place the micros very close together on the board.
6 Answers
What I have done when I needed to share a clock between micros is to have the crystal drive the oscillator on one micro and then use the oscillator output pin (typically CLKOUT or OSCOUT) from that micro to drive the second micro.
I would expect problems trying to drive two oscillators from the same crystal, if for no other reason than that the capacitance of the long PCB traces required to go between the two processors would cause a malfunction.
simulate this circuit – Schematic created using CircuitLab
-
2\$\begingroup\$ Some microcontrollers do have a separate clock output pin that is not connected to the crystal. \$\endgroup\$ Commented Jun 14, 2011 at 15:32
-
2\$\begingroup\$ The MSP430 processors can route any of the internal clocks (ACLK, SMCLK or MCLK) out of their I/O pins. I use the ACLK out (32768Hz) to supply the RTC backup clock to a GPS device for the times that its main power is off. \$\endgroup\$– uɐɪCommented Jun 15, 2011 at 7:30
That is not quite what you want. When you use a crystal to form an oscillator, you are using an inverter internal the the microcontroller to drive the crystal. If you connect both micros to the same crystal, they will fight and not work.
Therefore you will want to pick one of the two micros to serve as the crystal driver (configure as shown in section 6.2.6 of the datasheet) and the other micro to use an external clock input (6.2.1 of data sheet). Then change your schematic connection like this:
simulate this circuit – Schematic created using CircuitLab
Alternatively, if symmetry is desired you can use an external oscillator as opposed to a crystal. Then both could operate in external clock mode.
-
\$\begingroup\$ There is a definite need to adjust the upper capacitor in this set-up, if one wants the full benefits of the predictability of a crystal. \$\endgroup\$– AsmyldofCommented Aug 27, 2015 at 22:27
-
2\$\begingroup\$ so if C2=10pF (assuming about 10pF loading due to the CLKI input) and keep C1=22pF, right? \$\endgroup\$– MarkUCommented Aug 27, 2015 at 23:16
-
1\$\begingroup\$ @Passerby That's why I want to keep this question alive. The other question didn't provide any clear schematics. \$\endgroup\$– GisMofxCommented Aug 28, 2015 at 13:02
-
1\$\begingroup\$ No it will just come up as is if it was using any external clock. \$\endgroup\$ Commented Aug 28, 2015 at 13:08
-
1\$\begingroup\$ @GisMofx I flagged it asking for the answer to be merged, so that it gets moved over to the other question, so it can be preserved. \$\endgroup\$– PasserbyCommented Aug 28, 2015 at 13:29
The problem with that approach is that the connection to the second oscillator input will affect the capacitance on that pin, and alter the frequency slightly as well as reducing the crystal drive. It might not matter, though, and is very unlikely to prevent oscillation. When I've needed to do that for a product I've used a crystal oscillator module for both MCUs.
-
3\$\begingroup\$ A little extra capacitance on the oscillator output line isn't much of a problem. It's mostly the capacitance on the output side of the crystal, which is the oscillator input line, that forms the load on the crystal and needs to be about right to get the proper frequency within range. If you need to distribute the clock widely, put a CMOS buffer gate close to the micro with the crystal. \$\endgroup\$ Commented Jun 14, 2011 at 14:07
-
\$\begingroup\$ Also it's a great idea for EMI to avoid routing clock signals across boards. \$\endgroup\$ Commented Jan 23, 2014 at 20:35
You may build oscilator using cheapo invertor chip (0.1$), or specialized clock generator (slightly more expensive), and feed that clock to both uC.
Simply connection crystal to both would not work (reliably).
Make an oscillator out of your crystal and an inverter like BarsMonster suggested, and feed it into the input of a fanout distribution buffer IC. One fanout buffer output goes to the clock input of each MCU.
I can't really recommend a specific part without knowing what micros you're using, but you'd want to start with these filters:
- Type: Fanout Buffer (Distribution)
- Number of Circuits: 1
- Ratio - Input:Output: 1:2
-
1\$\begingroup\$ A list of 3000 parts is not really useful. Select one of them, and explain why it's a good choice. \$\endgroup\$– stevenvhCommented Jun 8, 2012 at 6:33
-
1\$\begingroup\$ I'm hesitant to put a specific part directly in the answer without knowing what logic levels etc. he's using. I 'll put in some search filter info to help narrow it down. For what it's worth, I'm currently using an oscillator with a TI CDCLVC1102. It looks like you could use a CDC3RL02 with a TXCO and no inverter as well. \$\endgroup\$ Commented Jun 9, 2012 at 9:38
If it's anything like the PICs I've used, you have an XTALout and and XTALin with the actual XTAL between them and caps (maybe around 22pf) to ground. Try connecting the XTALout of one to the XTALin of the other.
-
\$\begingroup\$ It's recommended to use a small series capacitor to drive the second oscillator from the output of the first. \$\endgroup\$– stevenvhCommented Apr 12, 2012 at 14:40