by jwhance » Sun Dec 11, 2011 8:27 am
I had a similar problem with the programming shield. The "blank" 328P that came with the shield from Adafruit worked fine but I had some 328s (not "P" but that doesn't matter) from DigiKey that would not program. It was like they weren't there. I had 5 brand new 328s and I just couldn't believe that all 5 were defective. I also have an AVRISP mkii and when attempting to use that, it also would not talk to the chips, I couldn't even read the device signature. I used the AVRISP to read out the fuse bits from my Arduino UNO and also the 328P from Adafruit. The only significant difference is in the LFUSE byte. The Atmel default is 0x62, which says Internal RC oscillator" for clock, while Ada and Arduino use 0xFF which specifies an external oscillator.
That got me into looking at HV (high-voltage) programming (it's not all that "high", just +12V) which will work no matter what. I found information at mightyohm.com on how to use an Arduino to program an ATMega using HV mode and I rigged up a circuit similar to his on my breadboard, sure enough the chips were good and were setup just like the datasheet says as far as the fuse bits are concerned. So I used Jeff's (from MightyOhm) to reset the fuse bits just like the Adafruit blank chip and voila! the programmer now works perfectly on the chips I "reset" with the HV programmer.
I'm still not sure WHY this was needed, after analyzing the fuses between Atmel and Adafruit the only one that I think might have been the problem is the internal vs. external oscillator setting. Atmel sets it to internal, the Adafruit 328P was set to external. This should not matter but my theory is that for whatever reason the ATMega328s I got from DigiKey would NOT run on internal RC oscillator in my setup. It's not clear why, perhaps my +5V is too high or too low, or too slow coming up or too noisy. If I get a chance I am going to reset the LFUSE back to the factory setting and see if I can get the problem to repeat.
But the bottom line is that unfortunately I was NOT able to find a way to use the blank 328s with the Adafruit programming shield without using the HV programming method to set them to EXTERNAL clock mode.
If anyone else has some other theories I'd be interested in knowing. I hope this helps... By the way, it's pretty easy to setup a work-alike for HV programming using the MightyOhm schematic and sketch. Just one tip on something I missed. The "VCC" signal on the HV programmer is NOT +5V power. It's an Arduino output used to power the device being programmed. I also just used an external +12V power supply since I didn't have a 12V boost converter handy. You could just switch it on/off manually but I rigged up a spare ULN2003 driver and resistor to switch the +12V on/off since I also didn't have the transistor array that MightyOhm uses. I only had a handful of 328s to reprogram so I just set it up, fixed them and moved on.