How to connect two devices to one crystal?

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi - I want to run an ATMEGA168 and a Microchip MCP2515 off of one 20Mhz crystal. What are the possible ways to do this? I do not have much board space, and I'm low on GPIOs on the ATMEGA168, so if there's a way to do it using only one of the oscilator pins on the 168 that'd be great.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not recomened, but you could try connecting the xtal to the 168, then connecting the Xtal_Out pin on the 168 to the Xtal_In pin on the micro chip with a 47pF cap in between.

Better would be to use a 20MHz oscillator and use that to drive both uP's. Cost is higher, board area is about the same, but much less chance of suffering high weirdness later on. Say after you've shipped a 1000 units.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think that this has been discussed here before. Try doing a search for it. I think that if you use a crystal oscillator instead of just a crystal it will solve both of your problems.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gibbon wrote:
Not recomened, but you could try connecting the xtal to the 168, then connecting the Xtal_Out pin on the 168 to the Xtal_In pin on the micro chip with a 47pF cap in between.

Better would be to use a 20MHz oscillator and use that to drive both uP's. Cost is higher, board area is about the same, but much less chance of suffering high weirdness later on. Say after you've shipped a 1000 units.


An oscilator is not a problem at all - but size is. The one I'm using is about 4.5x7mm square, surface mount. I feel like I looked a while back and had trouble finding anything smaller than that. Are there oscilators of that size? Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The ATmega168 will output the system clock on pin CLKO (PB0)
if the CKOUT fuse is programmed.
You find information in the datasheet on page 34 and on page 283.
Regards
Sebastian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just another idea:

Configure Timer 2 of one of your ATmega168 as a Asynchronous timer driven by a 32768 Hz
quartz. The standard diameter of this quartz is only 2mm

Use Timer 2 to calibrate the internal RC oscillator automatical by setting
SFR register OSCCAL.

Put out the calibrated system clock at Pin CLKO (PB0) to drive the second ATmega168.

You find information in the Atmel application notes AVR053 and AVR054 how to calibrate
the internal RC oscillator.

Not long ago a code example for automatic calibration of the internal RC oscillator
was posted in the avrfreaks forum. Take a look at it!

Regards
Sebastian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Use Timer 2 to calibrate the internal RC oscillator automatical by setting SFR register OSCCAL.

This is a good idea, except that he wants 20mHz, but the internal oscillator is only 8mHz. Even if he set OSCCAL to maximum, it wouldn't be anywhere near 20mHz.

Regards,
Steve A.

The Board helps those that help themselves.