Trouble programming standalone Atmega 328P and Arduino ISP

Hi,

I used an Arudino Uno to develop my code. I got in my PCB's for my project with blank Atmega328P's (link here).

As per this article, I got the impression that I could use the Arduino ISP (which I also purchased) to burn the bootloader onto the bare chips, as well as load sketches onto them.

I've followed the instructions on the previously mentioned page. I can load the bootloader with no errors from the Arduino IDE, I can also load the blink sketch with no errors. I have a LED attached to pin 0 on my board, so I change the appropriate lines in the code, but when I power up my board after uploading the sketch, I see nothing happening.

I've seen a few things about setting fuses properly, but I'm not quite sure how to do that using the Arduino IDE. My typical procedure has been to upload the bootloader to my board, then upload the sketch by using "Upload using programmer".

I would greatly appreciate some help from a more experienced person here...I'm having a devil of a time figuring this out and I am in over my head at this point. At this point, my goal is simply to get the blink sketch working on my boards...then move on to my actual code. :D

Please let me know if there is more info that would be helpful.

Hi, have you tried using a different pin to blink the led? Pins 0 and 1 are for serial programming.

Also do you have a 0.1uF bypass cap fitted?

Paul

Hi Paul,

Thanks for responding.

I was under the impression (can't remember where I had read it though...) that as long as my sketch doesn't set up serial communications it can be used as an output. I'm pretty sure I've tried different outputs, but I will double check. FWIW, I thought I had read somewhere that loading the bootloader should set up pin 13 to blink, which I did check, though got no response. Sorry...I've read so many things all the information is running together and I can't make heads or tails of most of it ::)

Yes, I have a 0.1 uF on VCC of the chip.

Everything you need but hardware is here: http://www.gammon.com.au/breadboard

stupendousman: as long as my sketch doesn't set up serial communications it can be used as an output.

Yes, you can, but not (conveniently) if you want to upload sketches via serial. And if you're not uploading via serial, why burn the bootloader?

stupendousman: I could use the Arduino ISP (which I also purchased) to burn the bootloader onto the bare chips, as well as load sketches onto them.

What did you mean when you said you purchased Arduino ISP? Its a sketch that comes free with the IDE.

Something else to check: do you have a 10K pull-up on the reset pin?

PaulRB: What did you mean when you said you purchased Arduino ISP? Its a sketch that comes free with the IDE.

This thing: https://www.arduino.cc/en/Main/ArduinoISP.

As an update, I tried loading just the basic blink sketch, using pin 13 as the output. Same result...no blinky on 13. Still no errors or anything in the upload process.

GoForSmoke...thanks for the link. I've seen that several times, but I'll take another look. I've had trouble on figuring out how it applies to my situation...not because it's not well written (it is), but I'm just kinda dumb sometimes...

Paul, I don't need to upload via serial, so it's not imperative in my application to have serial available. Why burn the bootloader? Because I don't know exactly what I'm doing at this point and trying to figure it out :D. I did read somewhere that burning the bootloader would set the fuses properly?

Also, yes, I have a 10K pullup for the reset.

I had forgotten that Arduino ISP existed as a piece of hardware and I assumed you were using your UNO with the ArduinoISP sketch loaded to program your blank atmega.

In fact, you could try that approach (UNO+ArduinoISP sketch) instead of your Arduino ISP hardware, to see if you have any more luck that way. (If you do, don't forget the 10uF reset-blocking cap on the UNO's reset pin.)

stupendousman: GoForSmoke...thanks for the link. I've seen that several times, but I'll take another look. I've had trouble on figuring out how it applies to my situation...not because it's not well written (it is), but I'm just kinda dumb sometimes...

Figure that your standalone if it's on a board is electrically pretty much the same as the breadboard Duino perhaps with more bits added and a surface mount chip(?) instead of the DIP chip shown.

To test the chip and program it whether on a board or breadboard you need to connect ground on the programmer Arduino to ground on the standalone and then power to power and then the SPI pins to program it. SPI on the 328P as shown in the blog is pins 10 to 13.

Then run the programs as shown and look for matching output to see it is right, then proceed with the process as outlined. The blog has extra options (other Arduino as ISP, program a bigger AVR, etc) that you won't have to cover so don't judge the curve by the blog length, just do the steps.

Nick provides better code than the old Arduino as ISP page. I know because I've done it both ways where before I had to modify files to get my 328P-PU chips to work (official is 328P-A with different ID #) and Nick's software recognizes more than those two.

As an update, I tried loading just the basic blink sketch, using pin 13 as the output. Same result...no blinky on 13.

Digital pin 13 is physical pin 19 on the 328 processor. How do you have your led connected?

I have a LED attached to pin 0 on my board,

To what what pin on the processor is pin 0 connected?

Can you provide a schematic of your board?

ATmega168/328-Arduino Pin Mapping https://www.arduino.cc/en/Hacking/PinMapping168

Thanks everybody for the help so far! Much appreciated.

Paul - I’m using an Uno now…we’ll see how far it gets me.

GoForSmoke - OK…I’ve started working my way through Nick’s post, here’s what I get:

Atmega chip detector.
Written by Nick Gammon.
Version 1.17
Compiled on Sep 21 2015 at 21:34:31 with Arduino IDE 10605.
Attempting to enter ICSP programming mode …
Failed to enter programming mode. Double-check wiring!
Programming mode off.

I’ve checked my wiring several times, all looks correct. In his blog he goes on to add a crystal, but I’ve already got a crystal on my board, the same one as is used on the Uno.

Schematics are attached.

cattledog - I don’t have a LED attached to pin 13, I just used my meter and didn’t see anything.

Are you connecting to pins by the chip pin numbers or by the Arduino pin numbers, the labels black or red on your schematic?

When I ran Nicks ISP sketches I think I didn't have to put a cap or resistor on the programmer UNO, but that was months ago and which revision UNO may make a difference.

I don't quite understand what you're asking. I did my best when drawing the schematics to match the Arduino pin numbers (which are the red net labels in my schematic) to the actual port names, as per the schematic part for the Atmega328P. I did all this by referencing the Uno schematic.

GoForSmoke: Are you connecting to pins by the chip pin numbers or by the Arduino pin numbers, the labels black or red on your schematic?

Are you referring to physically connecting to pins? The main one I'm trying to get working initially is the one that is shown, and is connected to PD0, which as I understand it, should be pin 0 on the Arduino.

I'm currently using a Rev 3 Uno. An earlier post said I needed to have a cap on the reset line, though I was confused because I looked and didn't see anything about the cap on Nick's post. I'll try that later today and see if that gets me anywhere and post back here.

NANO schematic with SMT 328 chip

Does the pin labeling on that chip look familiar? That is a surface mount 328. It has a pin 30.

Bare 328 DIP chip

Note pins 1 through 28 labeled as they appear on the physical chip. No pin 30.

UNO schematic

Pins 1 through 28 arranged to make drawing the schematic more clear.

If you connect the DIP using the SMT map or vice-versa and nothing else happens beside it doesn’t work then consider yourself lucky that Murphy didn’t notice.

This is the nature of troubleshooting, checking for missed details and fixing as needed.

I think I get what you're saying now. Sorry...I'm a bit dense sometimes.

When I'm connecting my Uno as a programmer to my circuit board, I'm wiring up according to the actual names of the pins, not the Arudino pin names/numbers.

So I'm running MOSI on the Uno to MOSI on my chip, MISO on the Uno to MISO on my chip, etc. Everything that I've been doing I've been referencing the Atmega pin names, not the Arduino pin names.

I'll quadruple check that I am in fact running all the correct wires to all the correct places.

It’s possible that something in your circuit needs a different step somewhere.
Possibly it will be obvious to a member with more knowhow than myself.

I still don’t know just what you’re trying to bootload, only that you think you have it wired right.

OK...slight progress, but not much.

I beeped out my connections from the Uno to make sure that the Uno and my standalone Atmega328 are connected pin for pin (MISO to MISO, etc.), and found the the RESET pin wasn't tied to my ISP header. I fixed that...but Nick's sketch is still telling me the same thing. I also tried putting a 10 uF cap on the reset line of the Uno as per an earlier suggestion in this thread...still no luck.

GoForSmoke - I'm sorry if I'm not being clear...I'm really new to this side of electronics, so a lot of the terms I'm still learning and mostly unclear about their meanings. I vaguely understand what a bootloader is, but I'm not totally sure if it's something I need just to run a simple program, etc.

What I'm trying to do right now is just be able to program my standalone Atmega328P on my circuit board with a simple blink program. On my hardware I have a LED connected to PD0 (referring to the Atmel pin names), which you should be able to see on my schematic. The main thing I'm after at this point is to make that LED blink. I don't know if I need to load the bootloader, etc., at this point.

Bootloader allows you to program the chip through the serial port.

But if you can't ISP a bootloader, you can't ISP other programs either.

If your target board has the same chip as the UNO, your schematic is garbage. If your target board has a little square surface mount 328, it might be good.

So when you tell me how you think it's hooked up, I won't bother guessing why.

My target board has a surface mount 328 (this one to be specific).

As I mentioned earlier in my original post, as far as I can tell, I am able to use my ISP to load the bootloader, both by using an Arduino ISP, and using an Arduino as an ISP.

When I connect my ArduinoISP to my target board and follow these instructions (https://www.arduino.cc/en/Guide/ArduinoISP), both for burning the bootloader and uploading a sketch, I get no errors back from the Arduino IDE. Maybe that doesn't mean anything, I really don't know at this point.