Using the Same Crystal for Multiple uC

Thread Starter

Sparky49

Joined Jul 16, 2011
833
Hi all,

is it possible to use the same crystal to act as a clock for multiple uC's? Would the sketch below the correct way to connect them?



If it is possible, are there any affects or design points I should watch out for?

Regards,

Sparky
 

Attachments

#12

Joined Nov 30, 2010
18,224
I have some doubts.
First, you will accumulate capacitance on the circuit board traces.
Second, one of the crystal inputs is powered.

Still, you can try it and I don't think anything will break.
 

crutschow

Joined Mar 14, 2008
34,450
You can't use a crystal for more than one micro. The clock operation depends upon active feedback in the clock generation circuit and you can't parallel active circuits in that manner. But you can use it for the clock generation of one micro and then you should then be able to buffer/amplify the clock signal from that to drive the other micro's clock inputs.
 

vortmax

Joined Oct 10, 2012
102
It might work, but I wouldn't rely on it. You would need to make sure only one chip is driving the crystal and the others are just taking the external reference. You still have the issue of the extra pin capacitances affecting the oscillator though... Not to mention that the driving ic will have some sort of feedback that can get thrown off

So the best solution is to buffer the clock signal. Most mcus will allow you to output a raw clock signal on a pin, which you can then feed to the other ics. You will also see this on other ics that require tight timing, for instance some CAN bus controllers have a "clock out" pin to let you drive the controller and MCU of the same clock.
 

atferrari

Joined Jan 6, 2004
4,770
In my design bidding farewell to the 16F84A, I built a dual signal generator (low audio frequencies) with two of them plus one crystal.

The clock is materialized with crystal + 2 caps in the first. The output from pin 15 OSC2/CLKOUT goes straight to pin 16 OSC1/CLKIN in the second. No buffer needed.
-------------------------------------------------
My initial design used a single 74HC??? as oscillator for both. Later I redesigned it as above. Wrong info deleted.

With a common clock, it is nice to see that after you change the phase between both outputs of the generator, it stays steady forever. :) (I am talking about the output of my audio generators, not about the clock).

Additional comment: both micros run exactly the SAME program but one of them always starts behind the other; always. Most probably your software should cater for that.
 

Attachments

Last edited:

vortmax

Joined Oct 10, 2012
102
Additional comments: both micros run exactly the SAME program but one of them always starts behind the other. Always.
I'm willing to bet you have a while loop towards the beginning of your code that pauses execution until the clock stabilizes. Mcu 1 won't output a clock signal until it has a stable input, so by definition, mcu 2 will always exit the loop after mcu 1, even if it is only a few ticks.

If you want synchronous execution, you are better off using a low frequency trigger (a second line). Some mcu's have timer modules with a pll that can sync to an external signal and apply multiplication and phase shift....otherwise you could use interrupts and just add in a few ticks of delay in the master (after asserting the line) to account for the ISR latency in the slave.
 

atferrari

Joined Jan 6, 2004
4,770
If you want synchronous execution, you are better off using a low frequency trigger (a second line). Some mcu's have timer modules with a pll that can sync to an external signal and apply multiplication and phase shift....otherwise you could use interrupts and just add in a few ticks of delay in the master (after asserting the line) to account for the ISR latency in the slave.
The code runs in sync because it has no option!

But, yes, the start it is not. Anyway, in this application I do not care.

One starting little after the other translates into a phase difference between the outputs. The user can correct it with the phase control or just leave it as is.

I recall trying to do what sp is asking about.
 

THE_RB

Joined Feb 11, 2008
5,438
In my design bidding farewell to the 16F84A, I built a dual signal generator (low audio frequencies) with two of them plus one crystal.

The clock is materialized with crystal + 2 caps in the first. The output from pin 15 OSC2/CLKOUT goes straight to pin 16 OSC1/CLKIN in the second. No buffer needed.

I've done that too, so I will second that!

The two PIC pins for the xtal osc are a high impedance input (OSC1), and a lowish impedance push-pull output driver (OSC2).

You can use the signal out of OSC2 to drive other digital inputs at osc speed. Obviously there may be an issue with wire lengths and capacitances, impedances etc.


Nice project Atferrari! :)
 

MrChips

Joined Oct 2, 2009
30,808
As others have said, you can use OSC2 to drive OSC1.
I have driven as many as nine separate PCBs with the same 8MHz MCU clock.
For this, I used a one-gate inverter to buffer the signal and another inverter on each receiving PCB.

Why did I do this? Because all MCUs and internal timers had to be synchronized.
 

MrChips

Joined Oct 2, 2009
30,808
I have multiple DSPs recording nuclear events. Each DSP must record the events and the time of each event to within 100ns. The only way I can see how to do this is to have all DSPs run from the same clock signal.

One DSP is considered the master and it has an 8MHz crystal on its on-chip oscillator. The oscillator signal is buffered by a single gate inverter SN74LVC1G14. Each slave board receives the clock via a similar gate.
 
Top