I am working on a project that uses two ATMega328P chips. I am using two because I am having compatibility issues with Pin Change Interrupts, The AdaFruit 12C Library, and Analog input. I am sure there is another solution but for now I want to run with this idea. One chip handles the internal work and the other handles the real world. The chips interact simply by triggering each others pins, no serial communication between the two is necessary. At current I am running everything with no issues on two Unos but as I begin the layout of my PCB I am wondering if I need a separate 16mhz crystal for each chip or if one crystal connected to both chips is good?
The two processor cannot share the crystal.
You can use CLOCK OUTPUT (CLKO / PB0) on the processor with the crystal and EXTERNAL CLOCK (XTAL1 / PB6) on the processor that does not have a crystal to share the clock signal. You will have to adjust the fuse bits for both processors.
As a bonus the two processors will run in lock-step.
Thanks for the answer, I am assuming by "lock step" you mean they will run in sync. Also while waiting for an answer i realized how ridiculous I was being... The Sketch that I am running is relatively small and I was using two chips so some functions would not get bogged down by others, realizing my code ran completely through faster then I can blink, I moved some wires and compiled the code into one file and everything runs just fine. For this project I'm good but definitely needed this info for another project
As far as I know, the default setting is a low power crystal oscillation, not the full swing. So it is a nice tuned circuit that can not be disturb.
However, when the full swing is selected with the fuses, I think that Xtal2 can be used for something else as well. Perhaps a buffer is needed, because anything connected to it will influence the circuit and capacitance.
Peter, I really have no idea what you just said or how it relates to the question, sorry i am an amateur at best. I do know it is possible to run the 328P with out an external clock, and both XTAL1 and XTAL2 are labeled on my pin map for PCINT (pin change interupt, just learned that yesterday!) and TOSC (no clue what that is!).
When the ATmega chip is set for external crystal, the XTAL1 is the input and the XTAL2 is the output.
The ATmega chip can use the crystal in two ways: a special lower voltage energy saving mode and the normal mode called "full swing". With the "full swing", the XTAL2 is a full 0V to 5V signal and can be used for other things. For example another ATmega chip.
However, the crystal with two 22pF capacitors will get disturbed easily. So a logic gate might be needed as a buffer to prevent that.
To set an ATmega chip for internal oscillator or external crystal or full swing is set with so called 'fuses'.