Go Down

Topic: two 328P with one crystal or resonator (Read 1 time) previous topic - next topic

sierrasmith71

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

Osgeld

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)
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

kf2qd

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

spirilis

#3
Apr 23, 2012, 10:44 pm Last Edit: Apr 23, 2012, 10:55 pm by spirilis Reason: 1
Fuse-wise, you need to make sure the primary one has Full-Swing Crystal Oscillator enabled[1] (not the Low-Power one you typically find enabled by default when you burn an arduino bootloader via the IDE), 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;
Quote
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:
Quote
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.


spirilis

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

SirNickity

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.

tim7

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.


liudr

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

CrossRoads

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
http://arduino.cc/forum/index.php/topic,70043.0.html
dual 1284
http://arduino.cc/forum/index.php/topic,70596.0.html
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

SirNickity

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.

Go Up