I want to know if I can connect two chips to the same crystal? I'm making a dual-core processor using Atmega2560, and I'd like to connect two chips to one crystal. I suspect that is a big no-no, but just asking for a second opinion?
No, you cannot use one crystal for two chips. What you can do is configure the second processor for an external clock, and use the clock output of the first one ( with crystal in full swing mode ) as an clock input to the second
I'm not sure what you mean. I am using an external crystal, not the internal one.
You can configure an Atmega to neither use an external crystal nor the internal RC oscillator but simply an input for an external clock.
If you configure the first Atmega using an external crystal in full swing mode, the out put of this oscillator can be used as the clock input for the second one.
In other words, easier to use two crystals.
Although that begs the question of whether the two chips will communicate correctly with each other, especially if there is a flaw in one of the chips and it happens to be a slightly different frequency.
Why? It doesn't matter if you have to set the fuses differently for both processors or if you set them the same. In either case you must set the fuses separately for each processer.
What is setting the fuses got to do with it? If you get chips with the bootloader already installed, isn't that irrelevant?
What is the communication method? SPI and I2C provide the clock for the slave. If it's a UART, then there is a certain amount of difference in bit time where the data can still be received correctly.
That was another question I was going to ask - which one is best. I was thinking about possibly (with any relevant circuitry necessary) connecting the TX3 and RX3 to their respecting pair. But SPI would be faster, no?
If you used UARTs, then each device can transmit when it wants, irrespective of whether the other is transmitting.
@markd833 @MicroBahner
True. Good point. I'll do that. So should I use two separate crystals, or just one, or only internal RC oscillator?
It depends on your use - anything is possible. If you want to use both with an Arduino bootloader, it is probably easiest to use separate crystals, as the programming of the bootloader usually sets the fuses this way.
Why
Haven’t tried but this should work.
One controller would use a crystal as normal, the device can output its system clock on the CLKO pin.
The clock output can be sent to the CLKO pin by setting a fuse.
This pin would go to the other controller’s EXTCLK pin and it’s CKSEL Fuses must be programmed to '0000' .
However, as mentioned, just use 2 (two) crystals or 2 (two) resonators .
Your question is actually asking if you can put two oscillators in parallel and be frequency controlled by one crystal.
My version:
You absolutely can not connect one quartz crystal to two MCUs because it acts as a resonator (similaro to a capacitor in an RC integrator circuit) for the oscillator which is inside those MCUs and cannot share the same crystal.
But if you don't want to spend one more line for CLK out on the master MCU, you can use a crystal OSCILLATOR instead of RESONATOR, or even make your own with matching CMOS inverter IC with the crystal: google for the schematic, it's simple. So, this will form a FULL-SWING oscillator, which can be connected to just a single input of the ATMEGA (since it's referenced to GND), leaving the second one as a data pin, and can be shared to any number of clocked units. You will have to set the right fuses in order to make this work. And the con of this method will be extensive switching noise because low-power sine wave @ 16-20 MHz is not the same as 5V p-p 16-20 MHz square wave.
Yes.
@LarryD
I'll just use two crystals. Seems easier.
No, sorry, you can't be. A core is not quite the same thing as a complete processor. I think you must be making a dual processor PCB board.
Yeah. I thought if it had two processors that it was dual core?
A core is a collection of processor logic on the IC die.
What is the point? A single STM32F103 for example, will run circles around two Mega2560's.
Not to mention having fewer pins to solder in most cases.