Go Down

Topic: Programming an Atmega328 using an Arduino Uno (Read 1 time) previous topic - next topic

Jumbosize

Hello all, I have a question about programming an Atmega328 chip on a breadboard using an Arduino Uno. So I'm using this little tutorial here: http://arduino.cc/en/Tutorial/ArduinoToBreadboard

Now I know that the tutorial specifically mentions this is for the Duemilanove and not the Uno, but just here me out!

A little while ago, maybe less than a month ago, I tried using this tutorial to create a breadboarded atmega328 (taken out of my Uno) to be programmed using my Arduino Uno. Now the weird thing is that even though it says the Uno doesn't work for this method, I was able to get it to work. I was able to compile and upload code using the Uno that I had hooked up to it (as directed in the tutorial) and it ran properly. Unfortunately I inevitably disassembled this circuit so I could continue using my Uno normally.

Now flashforward to a couple of nights ago:
I once again attempted to use the same setup to make a functioning breadboarded atmega328. Unfortunately, this time I had no luck. If I hooked up my Uno the same way and it just gave me an error in the IDE saying something about a sync error. Now here's probably where the problem really lies: If I hook up a preprogrammed Atmega328 (In this case one just running the standard pin 13 LED blink program) and set it up using an external crystal, regulated 5v power supply, and an led on pin 13, it won't even run. Nothing. However, If I take that same chip and put it back into my Uno, it will blink the built in led on pin 13 just fine. So this leads me to believe it really isn't the Uno's fault, nor is it the chip's fault... but then what is the problem!?

Another thing I'd like to mention is that over these past few nights I have disassembled and reassembled the circuit several times to see if I had perhaps missed something when I had wired it the night before, but I still have had no luck.

So does anybody have thoughts as to what the problem could be? If anybody has any clue what could be the problem here, it would be great if you could give some advice, thanks in advance!

Oh, one last thing: would pictures of my project be of assistance to anybody in helping with my problem? I'd be happy to take them if they would be help.

johnwasser


If I hook up a preprogrammed Atmega328 (In this case one just running the standard pin 13 LED blink program) and set it up using an external crystal, regulated 5v power supply, and an led on pin 13, it won't even run. Nothing. However, If I take that same chip and put it back into my Uno, it will blink the built in led on pin 13 just fine. So this leads me to believe it really isn't the Uno's fault, nor is it the chip's fault... but then what is the problem!?


Since the chip works in the UNO and not in the breadboard the only possible explanation is that the breadboard circuit is faulty.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

hiduino

Pictures are definitely helpful.  It is very easy to overlook something that others can spot easily.


Jumbosize

Okay, I went ahead and actually reassembled the circuit yet again on a different breadbaord (again with no luck :\). Here is a snapshot of it:



Hopefully it's not too hard to see, I got the best picture I could. This circuit doesn't incorporate the connections needed to program the chip, this is only to power it. Essentially all it has is the oscillator connected to the clock pins with two caps going to ground, an led connected to ground/pin 13, and power going to the + and - pins. The red wire going off screen is connected to the arduino uno 5v pin and the blue wire goes to the ground pin. The arduino is then connected to my PC via usb.

So does anybody know why this wouldn't power on?

hiduino

First thing, never connect a LED directly to an output pin and power or ground.  You should always have at least a 220 ohm or higher resistor in series with the LED.  Even though it may seem to work with no harm, you could be damaging the ATmega328P chip by drawing too much current through the port.

Which method of programming are you using?  Are you removing the m328p from the Uno, or have a separate m328p to program with?


Jumbosize


First thing, never connect a LED directly to an output pin and power or ground.  You should always have at least a 220 ohm or higher resistor in series with the LED.  Even though it may seem to work with no harm, you could be damaging the ATmega328P chip by drawing too much current through the port.

Which method of programming are you using?  Are you removing the m328p from the Uno, or have a separate m328p to program with?




Oh, I didn't realize it really mattered that much to put the led directly to the pin. I usually do use a resistor but I guess I didn't realize it was this important. I'll do that from now on, thank you!
As for your question, this was a chip taken directly out of my current Uno.

hiduino

#6
May 07, 2013, 04:31 am Last Edit: May 07, 2013, 04:33 am by hiduino Reason: 1

As for your question, this was a chip taken directly out of my current Uno.


Then you should be using this wiring setup to upload sketches.  Make sure you are selecting Uno board type from the Tools menu.  (You might need to remove the 10K ohm pull-up resistor as the Uno board already has that on the reset line.)




JoeO

Recheck the 22pf capacitors.  They look kinda large to be only 22pf.

johnwasser


Recheck the 22pf capacitors.  They look kinda large to be only 22pf.

That's  what I was thinking.  If they are something like 0.22 uF (microfarad) they would be 10,000 times too large.  A microfarad is a million times larger than a picofarad.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

dannable

What about the resistor on pin1 to hold reset high?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

afremont

I agree with others that the caps on the crystal look kind big for 22pF.  Another thing I'd try is adding .1uF bypass caps to the power leads of the 328, right on the breadboard near the pins. 

If the chip responds and runs the blink program when it's in the board, it should do so on the breadboard.  It's not starting for some reason.  You might try a manual reset after you apply power to the breadboard.  I don't know how picky the AVRs are, but I've had trouble with the low power PIC chips not starting without a bypass cap on the power or if the power wires leading to the chip were long and thin.  This made the rise time too slow and PIC wouldn't come out of reset.
Experience, it's what you get when you were expecting something else.

hiduino

I tested the tutorial with my Uno.  Took out the m328p and breadboarded it according to the diagram and it worked fine.  I uploaded Blink and tried various delays.  I did leave off the external pull-up resistor on the reset pin, again because the Uno board is already providing that.


Jumbosize

Thanks for all of the help, guys. I found out that the problem was as many of you suggested the caps on the crystal were too high. They were actually .1uF caps that somehow managed to find themselves into a bag in my drawer labeled 22pF. I should really be more careful next time I do some cleaning up...

I just want to say I really appreciate how helpful the arduino community is. I've had many silly questions like this (and I'm sure many to come...) that you guys have happily answered for me.

Thanks!

Go Up