Pages: [1]   Go Down
Author Topic: two 328P with one crystal or resonator  (Read 998 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Writing Arduino code is fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

SE USA
Offline Offline
Faraday Member
**
Karma: 40
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged


South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1023
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Maryland, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 162
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: April 23, 2012, 03:55:11 pm by spirilis » Logged

Maryland, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 162
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Anchorage, AK
Offline Offline
Edison Member
*
Karma: 37
Posts: 1149
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Switzerland
Offline Offline
Sr. Member
****
Karma: 6
Posts: 375
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 65
Posts: 6935
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 443
Posts: 23837
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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.

Anchorage, AK
Offline Offline
Edison Member
*
Karma: 37
Posts: 1149
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: