Atmega328 will not "retain" programing

I have an Atmega328 that I programed on a breadboard with just a simple rapid blink program. I programed it using my arduino uno. Then I started thinking to myself if I have to remove the microcontroller from the arduino to program a chip on the breadboard then why not just place the atmega I want to program in the arduino and program it that way instead of spending extra time building a circuit. So after programing my new atmega328/w bootloader in the arduino it will only retain the new program until power is lost. After power is lost and restored the program reverts back to the rapid blink program I had on it first. Is this atmega bad or did I not hold my mouth right when programing it?

Did you use the Arduino IDE to install the bootlaoder?

Edit: typographical mistakes corrected.

The atmega 328 already had the bootloader on it when I purchased. But I can try to load the bootloader again. This chip was purchased off of ebay so it may just be crap.

The problem is indicative of a bug in an early version of optiboot. I suggest installing the latest version of optiboot on the new processor.

The problem can also be caused by the auto-reset bug. Which revision is your Uno?

I went to radio shack to buy the correct capacitors so I could bootload with my 2560 because you told me that "size does matter" lol and I ended up just buying a new uno so it is the rev 3. I will try to reload the optiboot and I will let you know how it goes in a few minutes

I ended up just buying a new uno so it is the rev 3

Excellent. You do not need to worry about the auto-reset bug.

I will let you know how it goes

Please do.

hey coding, another quick question? I am setting up the circuit to run the optiboot. I know I need 18-22pf capcacitors but im out. I have a bunch of 10pf capacitors. Is there any way to combine to tens correctly to make the value 20pf?

jeremydial1981:
hey coding, another quick question? I am setting up the circuit to run the optiboot. I know I need 18-22pf capcacitors but im out. I have a bunch of 10pf capacitors. Is there any way to combine to tens correctly to make the value 20pf?

Two 10pF in parallel = 20pF

ok thanks

Ok, so here is what I found. I tried to reload otpiboot on the atmega in question. The bootloading failed and the error was "Expected signature for ATMEGA328P is 1E 95 OF, double check chip or hit -f to override this check. (just curious, how exactly would I hit -F to override). Just to be sure I took 3 brand new atmega328's I purchased from sparkfun and uploaded optiboot with my current setup and it worked perfectly. I am assuming that the atmega in question is faulty or counterfeit as it was purchased off of ebay. What do you guys think?

Is it a 328 or a 328P?

My avrdude.conf has ATMEGA328P signature as 1E 95 0F and I had to change the 0F to 14 to burn an ATMEGA328PU. The PU chip costs less (cheapest one Mouser had, LOL), maybe you got one of those?

OK, I see it now. the chip in question is a 328- pu. SO what do I need to do to change the ID?

You need to find where your avrdude.conf file is. Make a backup copy or two. Edit it with a text editor. Find the first occurence of ATMEGA328 and you should see a block that starts with this:

#------------------------------------------------------------

ATmega328

#------------------------------------------------------------

part
id = "m328p";
desc = "ATMEGA328P";
has_debugwire = yes;
flash_instr = 0xB6, 0x01, 0x11;
eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
0x99, 0xF9, 0xBB, 0xAF;
stk500_devcode = 0x86;

avr910_devcode = 0x;

signature = 0x1E 0x95 0x0F;
pagel = 0xd7;
bs2 = 0xc2;
chip_erase_delay = 9000;

Change the signature line to look like this:
signature = 0x1E 0x95 0x14;

Then copy that with a name like avrdude.conf.328pu so when you switch back you don't lose the edit.

You only use that when you're programming a 328PU. I used the original avrdude.conf to load the Arduino ISP sketch to my 328P UNO then switched to burn the bootloader to a 328PU on a breadboard.

Take extra care burning bootloaders! I think I bricked on 328PU before I got it right on another, and I only have two! NP, I can buy more later.