ATmega328P-PU with Arduino as programmer + NRF24L01

Hi,

I'm sure this question has been answered somewhere before, but I am getting really confused googling around for my answer so I thought I'd ask the experts directly.

I have an Arduino UNO, and an ATMega328P-PU. I want to be able to load regular avr programs onto the ATMega using only the Arduino [no crystal or capacitors](I have a usbasp programmer on order but that will take 3 weeks to get here), but I'm confused as to whether I need a bootloader or is that for a different purpose?

I've tried this tutorial (on a completely fresh ATMega328P-PU) for using the Arduino as an ISP: AVR Programming 02: The Hardware | Hackaday ... -hardware/ and used the wiring on this page http://arduino.cc/en/Tutorial/ArduinoISP (the bottom left one with no capacitors) but I get a "Yikes! Invalid device signature." from avrdude.

Do I need different wiring? Do I need a bootloader here? Do I need to change the command I send to avrdude (I changed the m168 to m328p)?

My goal is to start learning more about avrs since I am doing my thesis this year and will be working on a telemetry system for a UAV with an XMega and XBees + Processing. I want to be able to firstly put a program on the ATMega328P-PU I have, then when I'm comfortable with that I'll connect one of the two NRF24L01s RF modules I have to it, and another to my Arduino to simulate my telemetry setup sending data back and forth wirelessly(I start my thesis in a month).

Any guidance for setting up my ATMega or anything else in my post would be greatly appreciated.

Thanks,
Rik.

I've tried this tutorial (on a completely fresh ATMega328P-PU) for using the Arduino as an ISP...

How did you disable reset?

Is that the 10uF capacitor in step 5 in the arduino.cc tutorial? Would that be the problem?

Dblade4:
Is that the 10uF capacitor in step 5 in the arduino.cc tutorial?

Yes.

Would that be the problem?

Did you following the instructions?

I was following the hackaday tutorial which did not mention anything about it but I now see that he is using a dueminalove. I used the arduino.cc page only for the wiring diagram.

So this is all I will need to do then, all the other steps are right for uploading simple .hex programs to the atmega328p-pu? I will try the hackaday tutorial again but with the 10uF capacitor, and the exact circuit shown on the bottom left of the arduino.cc tutorial.

And do I just use '328p' in avr dude even though my atmega has 'pu' at the end?

Dblade4:
And do I just use '328p' in avr dude even though my atmega has 'pu' at the end?

Yes. The "pu" is the package (DIP).

I just tried the exact configuration (bottom left diagram and with a 10uF capacitor from ground to reset) on the arduino.cc website for ArduinoISP, but I am getting the same "Yikes .. Invalid Device Signature" problem.

Could it be that I need a crystal (16MHz)? I thought it was unnecessary with that configuration?

Dblade4:
Could it be that I need a crystal (16MHz)? I thought it was unnecessary with that configuration?

It's nothing to do with configuration.

If the chip has previously been set to use a crystal then you need a crystal to be able to unset it again.

fungus:

Dblade4:
Could it be that I need a crystal (16MHz)? I thought it was unnecessary with that configuration?

It's nothing to do with configuration.

If the chip has previously been set to use a crystal then you need a crystal to be able to unset it again.

How can I check this? I bought this ATmega http://www.ebay.com.au/itm/160768276199?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649#ht_2823wt_1139

Dblade4:
I am getting the same "Yikes .. Invalid Device Signature" problem.

Post verbose output from avrdude. Please
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags.

Could it be that I need a crystal (16MHz)?

Maybe.

I thought it was unnecessary with that configuration?

Is it a brand new processor? If "yes" then a crystal is not necessary.

I will post verbose output tonight when I get home.

These are the steps I took to upload a hex file to my atmega328 using my Arduino UNO as an ISP:

  1. Installed the latest WinAVR which comes with avrdude.
  2. Connected Arduino to PC, uploaded ArduinoISP using Arduino IDE 1.01 [board selected is the UNO].
  3. Wired up my atmega exactly like this:
  4. Downloaded "main.hex" from this page http://hackaday.com/2010/10/25/avr-programming-02-the-hardware/ under heading "Flashing firmware with AVRdude
    " - this is supposed to be a program that blinks an LED. This is what it looked like except I had 5V running from the Arduino to the 5V rail like in the picture above and GND from the Arduino to the GND rail (and no other power source).

    [This is a picture from the hackaday website, not one that I took]
  5. Opened up command prompt, navigated to the directory with the .hex file, and used:
    avrdude -P COM7 -b 19200 -c avrisp -p m328p -U flash:w:main.hex where COM7 is the port my Arduino was connected to [I got this line from the hackaday tutorial].

Then when I found out I needed a 10uF capacitor between GND and RESET on the Arduino, I repeated all the steps from step 3 onwards with the capacitor in. Note that I had no other capacitors or a crystal. This is a fresh ATMega328P-PU that I got from here: http://www.ebay.com.au/itm/160768276199?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649#ht_2823wt_1139

Both ways yielded an invalid device signature (I think it was 0x000000) error immediately. Forcing it with -F took about a minute to complete with a few different steps going from 0-100%, but verification at the end failed [I suspect it didn't connect/upload at all].

Post a photo of YOUR connections, not the ones you are trying to copy.

That last photo also states that there is no power connection between breadboard and Arduino, but you should always have a common Ground, so connect the breadboard battery negative to Arduino Gnd (or even simpler just power the breadboarded ATMega from the Arduino during programming).

Post a photo of what you have and then people can help troubleshoot. Often someone thinks they are following an example but usually the reason it doesn't work is because they have actually wired something wrong, even though they think they haven't. :wink:

tack:
Post a photo of YOUR connections, not the ones you are trying to copy.

That last photo also states that there is no power connection between breadboard and Arduino, but you should always have a common Ground, so connect the breadboard battery negative to Arduino Gnd (or even simpler just power the breadboarded ATMega from the Arduino during programming).

Post a photo of what you have and then people can help troubleshoot. Often someone thinks they are following an example but usually the reason it doesn't work is because they have actually wired something wrong, even though they think they haven't. :wink:

I will post a photo tonight. And I was using the Arduino's power (Both 5V and GND from the Arduino were connected to the power rails), and no battery.

That's good as it will be much better than trying to troubleshoot from the things you are attempting to follow.

I believe you did say that you were getting a device signature error? If so then I would look at the 328 chip and check it is actually a 328P-PU and not just a 328-PU, as they have different signatures. The ad you linked to does state it's a P-PU, but that doesn't mean that's the chip you actually received. :wink:

I just uploaded some code that someone posted for me that output a 1MHz clock to Digital pin 13 which he told me to connect to XTAL1 on the atmega, and now it works! Does this mean my chip was setup to use an external clock (though I thought fresh chips are setup to use their own 1MHz clock)? Can I set it to use its own clock?

Dblade4:
I just uploaded some code that someone posted for me that output a 1MHz clock to Digital pin 13 which he told me to connect to XTAL1 on the atmega, and now it works! Does this mean my chip was setup to use an external clock...

Yes.

(though I thought fresh chips are setup to use their own 1MHz clock)?

They are. Which means you or someone between you and the factory altered the fuses.

Can I set it to use its own clock?

Yes. With no tuning, the internal oscillator is ±10% of the frequency. With tuning you can expect ±1% (which is more than good enough for most applications).