Using the Same Crystal for Multiple uC

Discussion in 'General Electronics Chat' started by Sparky49, May 31, 2014.

  1. Sparky49

    Thread Starter Active Member

    Jul 16, 2011
    834
    417
    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?

    [​IMG]

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

    Regards,

    Sparky
     
  2. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,016
    3,789
    The high impedence input should let it work. If anything, it is a good experiment.
     
    Sparky49 likes this.
  3. #12

    Expert

    Nov 30, 2010
    16,277
    6,788
    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.
     
    Sparky49 likes this.
  4. crutschow

    Expert

    Mar 14, 2008
    13,001
    3,229
    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.
     
    #12 and Sparky49 like this.
  5. vortmax

    Member

    Oct 10, 2012
    103
    18
    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.
     
    Sparky49 likes this.
  6. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,648
    762
    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.
     
    Last edited: May 31, 2014
  7. vortmax

    Member

    Oct 10, 2012
    103
    18
    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.
     
  8. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,648
    762
    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.
     
  9. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305

    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! :)
     
    atferrari likes this.
  10. MrChips

    Moderator

    Oct 2, 2009
    12,439
    3,360
    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.
     
    atferrari, THE_RB and Sparky49 like this.
  11. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Sounds intriguing!

    Care to share any more details MrChips?
     
  12. MrChips

    Moderator

    Oct 2, 2009
    12,439
    3,360
    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.
     
    THE_RB likes this.
Loading...