Hello
I was searching to see if it were possible to share a crystal between two atmega328p-pu. I found some threads such as
http://arduino.cc/forum/index.php/topic,127418.0.html
I cannot configure one to take the clock from the other (not just because I wouldn't know how to!) as I want to make a programmer and share the crystal if possible.
What I would like to know is:
How does the arduino use the two pins to get a 'clock' from the crystal?
Why can I not share them?
Thanks
Mrs Z
Reply #10 in that thread tells you what you need.
I found that installing a 2nd 31 cent crystal and two 3 cent caps was easy also, no messing with the fuses.\
The datasheet discusses how it uses internal buffers to make the crystal oscillate to make the system clock.
CrossRoads:
Reply #10 in that thread tells you what you need.
I found that installing a 2nd 31 cent crystal and two 3 cent caps was easy also, no messing with the fuses.\The datasheet discusses how it uses internal buffers to make the crystal oscillate to make the system clock.
http://www.atmel.com/devices/ATMEGA328P.aspx
Thanks for this. It wasn't the cost. I have the parts. It was the space on the board and the knowledge.
Alternatively (and saving a pin), connect the crystal + caps to one of the atmega mcus as usual. Then connect XTAL2 of that chip to XTAL1 of the other. You might possibly need to use a series resistor of about 1K between those 2 pins, but I doubt it. No need to change any fuses.
"It was the space on the board"
You can also install parts on the bottom of the board to save space, and surface mount parts under DIP parts in sockets, lots of ways to save on room.
You can't see them, but this has parts under the DIP - the caps for the crystal, and the Reset parts
This has SMD & thruhole parts on both sides
Hi
Thank you both for your replies. I have tried your suggestion dc42 with two chips on a breadboard running blink and it seems to work. Unfortunately, my arduino as ISP doesn't However, it does not work with the crystal and caps either so I will have to investigate as I recently upgraded and it could be a lot of things causing the problem.
Thanks for your help.
It was very kind of you to post the suggestions for saving space on my board, CrossRoads. That kind of sophistication is a little beyond me at the moment. I only have pad or vero board and a simple 12W soldering iron I bought at Homebase 20 years ago. Maybe next year ... who knows what Santa might bring :D.
Thanks again
Mrs Z
MI PREGUNTA ES QUE ESTOY COMUNICANDO DOS MODULOS DE RF CON 2 ARDUINO LO QUE QUIERO ES SACAR EL ATMEGA 328P PARA EL EMISOR Y HACERLO INDEPENDIENTE YA QUE QUIERO HACER VARIOS PERO CUANDO GRABO MI PROGRAMA ALIMENTO EL MICRO NO PUEDO COMUNICAR MI MENSAJE DEL EMISOR pero con el micro en el arduino si normal ES DECIR NO LLEGA el mensaje NO SE QUE PUEDO HACER LE PUSE UN CRYZTAL DE 16.000 Y dos Condesandores de 22uf ? me pueden quitar mi duda?
Hi angel12345
Thank you for your reply. Google translate says it is Spanish and that you said
"My question is that I am calling DOS RF MODULES WITH 2 ARDUINO IS WHAT I WANT TO GET THE ISSUER FOR ATMEGA 328p INDEPENDENT AND DO IT BECAUSE I WANT TO DO BUT when I record MY OTHER PROGRAM CAN NOT FEED THE MICRO TRANSMITTER communicate my message but with the in micro arduino if normal ie not get the message I CAN DO NOT YOU PUT AN cryztal Condesandores 16,000 and two of 22uf? I can remove my doubt?"
Perhaps you could help with the translation as I do not speak any Spanish at all.
angel12345:
MI PREGUNTA ES QUE ESTOY COMUNICANDO DOS MODULOS DE RF CON 2 ARDUINO LO QUE QUIERO ES SACAR EL ATMEGA 328P PARA EL EMISOR Y HACERLO INDEPENDIENTE YA QUE QUIERO HACER VARIOS PERO CUANDO GRABO MI PROGRAMA ALIMENTO EL MICRO NO PUEDO COMUNICAR MI MENSAJE DEL EMISOR pero con el micro en el arduino si normal ES DECIR NO LLEGA el mensaje NO SE QUE PUEDO HACER LE PUSE UN CRYZTAL DE 16.000 Y dos Condesandores de 22uf ? me pueden quitar mi duda?
Menuda falta de respecto !
- Escribes una pregunta totalmente aislada a la del hilo principal
- Escribes en mayusculas (e incluso minusculas)
- Escribes en español en una sección del foro donde todo esta en ingles.
haztelo mirar.
Zaplady dont worry about his reply it was totally out of place as he is asking a completely new question, not helping at all to the original thread.
Thank you both for your replies. I have tried your suggestion dc42 with two chips on a breadboard running blink and it seems to work. Unfortunately, my arduino as ISP doesn't
This is an interesting comment [although the 2 in spanish are a little more interesting ;-)].
I would have thought that dc42's suggestion would work fine, although there may be some
invisible startup issues. To get it to go, you would have to be very careful to choose the
correct pins - ie, osc output pin [on chip with xtal] hooked to osc input pin on the other
[and with its osc output pin not connected]. I wouldn't think the fuse settings would matter
on the 2nd chip, but probably need to use full-swing fuse setting on the first. ???
Good point, you might have to use the full swing crystal oscillator mode on the first chip to make it work reliably. Alternatively, connect a capacitor of about 100pF to 1000pF from XTAL2 (output) of the first chip to XTAL1 (input) of the second instead of a direct connection. There is an internal resistor between XTAL1 and XTAL2 that will set the correct bias for the second chip.
Assuming you have the crystal running on the first chip, you could also try setting the CLKO fuse on the first chip which would put the system clock on the CLKO pin (pin-14 on the 328P) and then feed that into the second chip XTAL1 input. The second chip will need to have the fuses set for external clock source.
I did this a little while ago with two Unos, driving both boards with a single crystal:
Details here: Arduino Forum
A few things to note:
- The slave expects a full-swing signal. That means that you cannot drive it directly from the master's crystal oscillator signals when configured for a low-power clock. So you "use up" an extra pin on the master to generate the CLKO signal used by the slave.
- The start-up time is determined by the on-board low-precision oscillator. That means that even with a shared clock the two processors will not start executing precisely together. However once running the phase-shift will remain constant.
- Once programmed for an external clock, the slave needs that external clock to be present whenever it is being re-programmed. That can be awkward when adjusting the fuse settings. Luckily many of the software ISPs out there generate an emergency clock signal which can be used.
- I used unmodified Uno boards for this test, and discovered that you do not need to remove the inactive crystal / resonator on the slave. It appears not to disturb the clock signal coming from the master. The crystal signals are not broken out on the Uno (competitors note -- this is something you could add!), so I needed an IC probe to make the connection.
Hope that's useful, or at least interesting!
tim7:
- The slave expects a full-swing signal.
You configured the slave fuses for an external clock. If instead you configure it for a crystal oscillator, then it should work with a much smaller clock input signal to the XTAL1 pin - such as from the XTAL2 pin of the other mcu. But then you lose the PB7 pin on the slave, because it becomes XTAL2. So you have a choice between using 3 clock-related pins on the master and 1 on the slave, or 2 on the master and 2 on the slave.
Right. That would also enable the feed-back electronics in the slave's clock, meaning I would have had to remove the resonator from the slave board. In a custom design of course that problem would not have existed.
dc42:
Alternatively (and saving a pin), connect the crystal + caps to one of the atmega mcus as usual. Then connect XTAL2 of that chip to XTAL1 of the other. You might possibly need to use a series resistor of about 1K between those 2 pins, but I doubt it. No need to change any fuses.
Fabulous dc42. I read the instructions this time ( ) and this does work. I have downloaded a couple of sketches with this configuration and it seems fine. However, I also bought a $3 programmer from china :D.
Thanks again
Mrs Z