two 328P with one crystal or resonator

Hi Folks:

If I put two 328P TQFP chips on one board (I think I have a good reason to do this!) can I save a few cents and space by providing only one resonator to drive both chips?

Thanks in advance for even thinking about the answer!!! David G.

Gaithersburg MD

er um yea if you want to mess about fuse settings what you can do is have one use the resonator, then output that signal on another pin then set the second one to use an external clock source, so you would use 3 pins on the first chip (xtal 1, 2 and clockout) and 1 pin on the second chip (xtal 1 / clockin)

2 resonators don't take up much space and then each device can be independant for testing/troubleshooting. Always plan for troubleshooting...

Fuse-wise, you need to make sure the primary one has Full-Swing Crystal Oscillator enabled1, the ClockOut fuse bit is enabled, then PORTB0 (aka digital pin 8 on an arduino) has to go into XTAL1 on the 2nd one and that one needs its fuses set to External Oscillator. Likewise, digital pin 8 on the first processor can't be used for I/O.

For the 328P, example fuse settings...

Master (with the crystal across XTAL1/XTAL2 and 22pF ceramic caps between each XTAL line and GND)- Extended fuse: 0x05 (BOD enabled) High fuse: 0xDE (Self-Programming enabled, Reset Vector=Bootloader) Low fuse: 0x97 (CLKO, SUT=01, CKSEL=Full Swing Oscillator) **note that the exact fuses may differ depending on what kind of crystal/resonator you have: A quartz crystal with BOD enabled, as we have it here, should have SUT=01 with CKSEL bits = 0111, yielding a low fuse of 0x97 A ceramic resonator with BOD enabled should have SUT=10 and CKSEL bits = 0110, which would yield a low-fuse of 0xA6.

Slave processor (with master's PORTB0 pin going into slave's XTAL1, no caps required and XTAL2 suddenly becomes PORTB7, a usable I/O pin)- Extended fuse: 0x05 High fuse: 0xDE Low fuse: 0xC0 (SUT=00, CKSEL=External Oscillator)

Note [1]: This advice comes from page 28 of the ATmega48A/48PA/88A/88PA/168A/168PA/328/328P datasheet;

Low Power Crystal Oscillator Pins XTAL1 and XTAL2 are input and output, respectively, of an inverting amplifier which can be configured for use as an On-chip Oscillator, as shown in Figure 8-2 on page 29. Either a quartz or ceramic resonator may be used.

This Crystal Oscillator is a low power oscillator, with reduced voltage swing on the XTAL2 output. It gives the lowest power consumption, but is not capable of driving other clock inputs, and may be more susceptible to noise in noisy environments. In these cases, refer to the "Full Swing Crystal Oscillator" on page 30.

... There is some confusion though, because the Clock Output Buffer section implies any clock may be used:

Clock Output Buffer The device can output the system clock on the CLKO pin. To enable the output, the CKOUT Fuse has to be programmed. This mode is suitable when the chip clock is used to drive other circuits on the system. The clock also will be output during reset, and the normal operation of I/O pin will be overridden when the fuse is programmed. Any clock source, including the internal RC Oscillator, can be selected when the clock is output on CLKO. If the System Clock Prescalar is used, it is the divided system clock that is output.

edit: Think I screwed up my hex for the fuse bits, check it with a fuse calculator to be sure (just corrected it)

Someone on here was talking about doing this recently by just connecting the same crystal to both chips. IIRC, you leave Xtal2(?) unconnected on one of them. The idea being that whichever pin it was is used to kick-start the oscillation, so you only needed one of the ICs to do that.

Not sure if that worked out for them, or if this is even sound engineering, but there was a discussion on it. I think the topic was something about designing a "dual-core" Arduino.

You can use CLKO (=PB0) from the 1st chip to drive XTAL1 (=PB6) on the 2nd - in which case the crystal or resonator can be low-power.

You can also use XTAL2 (=PB7) from the 1st chip to drive XTAL1 (=PB6) on the 2nd - in which case the Full Swing Crystal Oscillator should be configured.

CrossRoads did this with one of his recent designs. Ask him or find his posts.

I only designed it, didn’t actually build. Be easy enough to add a 2nd socket & processor to my wirewrap test board & try it out.
dual 328,70043.0.html
dual 1284,70596.0.html

If I remember tonight, I'll drop a couple of 8As on a breadboard bunking up with a single resonator and see if the smoke stays in.