Go Down

Topic: ATMega328p to breadboard - following Gammon's guide, but stuck uploading sketch (Read 332 times) previous topic - next topic

Strainger

Hi, and thank you for reading.

I want to put a ATMega328p chip on a breadboard, using the internal 8mHz internal clock to create a minimal PIR motion detector. I am following Nick Gammon's breadboard guide (http://www.gammon.com.au/breadboard) to get the bootloader on the chip. I have also tried the method described on https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard.

Running Nick's Atmega_Board_Detector sketch, I get the following results:

Quote
Atmega chip detector.
Written by Nick Gammon.
Version 1.20
Compiled on Oct 16 2017 at 12:41:31 with Arduino IDE 10804.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x95 0x0F
Processor = ATmega328P
Flash memory size = 32768 bytes.
LFuse = 0xE2
HFuse = 0xDA
EFuse = 0xFD
Lock byte = 0xCF
Clock calibration = 0xBA
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 2048 bytes starting at 7800

Bootloader:

7800: 0x0C 0x94 0x34 0x3C 0x0C 0x94 0x51 0x3C 0x0C 0x94 0x51 0x3C 0x0C 0x94 0x51 0x3C
7810: 0x0C 0x94 0x51 0x3C 0x0C 0x94 0x51 0x3C 0x0C 0x94 0x51 0x3C 0x0C 0x94 0x51 0x3C
7820: 0x0C 0x94 0x51 0x3C 0x0C 0x94 0x51 0x3C 0x0C 0x94 0x51 0x3C 0x0C 0x94 0x51 0x3C

.....

MD5 sum of bootloader = 0x27 0xEB 0x87 0x14 0x5D 0x45 0xD4 0xD8 0x41 0x44 0x52 0xCE 0x0A 0x2B 0x8C 0x5F
Bootloader name: ATmegaBOOT_168_atmega328_pro_8MHz

First 256 bytes of program memory:

00: 0x0C 0x94 0x5C 0x00 0x0C 0x94 0x6E 0x00 0x0C 0x94 0x6E 0x00 0x0C 0x94 0x6E 0x00
10: 0x0C 0x94 0x6E 0x00 0x0C 0x94 0x6E 0x00 0x0C 0x94 0x6E 0x00 0x0C 0x94 0x6E 0x00
20: 0x0C 0x94 0x6E 0x00 0x0C 0x94 0x6E 0x00 0x0C 0x94 0x6E 0x00 0x0C 0x94 0x6E 0x00
30: 0x0C 0x94 0x6E 0x00 0x0C 0x94 0x6E 0x00 0x0C 0x94 0x6E 0x00 0x0C 0x94 0x6E 0x00

When connecting an LED to D13 (pin 19 on chip), it starts to blink like you would expect in standby mode. Running Nick's Atmega_Board_Programmer sketch, I get:

Quote
Verifying ...
No errors found.
Done.
Programming mode off.
Type 'C' when ready to continue with another chip ...
The problem begins when trying to upload a sketch. I tried this FTDI232 usb converter:
https://github.com/jandelgado/arduino/wiki/FTDI232-USB-to-Serial-converter

I also tried the instructions under "Uploading Using an Arduino Board" on the ArduinoToBreadboard page.
Wiring as follows:

Arduino - ATMega
Reset - pin1
0 - pin2
1 - pin3
5V - pin7 and pin22
GND - pin8 and pin20

LED+ to resistor to pin19
LED- to pin22

In all cases I am unable to upload even the Blink sketch.

Quote
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x91
I am using Arduino IDE 1.8.4. I have tried various ATMega328 chips.

Any input will be greatly appreciated!


groundFungus


Strainger

How are you resetting the chip during upload?
I hope you are referring to pressing the reset button on the Arduino uploader board, right before upload? That is with Reset connected to chip pin1. If not, my ignorance is exposed... :o

But, Googling "reset during upload", I stumbled onto this page:
https://arduino.stackexchange.com/questions/13292/have-i-bricked-my-arduino-uno-problems-with-uploading-to-board

Troubleshooting your BOARD, it mentions that the power-LED on the board should flash when plugging/unplugging USB. Mine doesn't, just instant on. Should it flash when Arduino is connected as uploader to chip on breadboard?

Also, it mentions that RX and TX LEDs should flash while uploading. Mine stays dead.

Just to confirm: this is a different and "good" Arduino Uno.

Thank you for your time!



DrAzzy

Pin1 of the FTDI adapter must not be connected to reset of the Arduino - this pin goes low when the serial port is opened, and would hold the chip in reset, preventing the bootloader from running.  You need to connect one side of a 0.1uF capacitor to reset, and the other side to the DTR or RTS pin of the serial adapter - this and the 10k pullup on reset form an RC that converts the high to low transition into a low pulse, which resets the chip but then allows it to start, the bootloader runs, and it can upload the sketch.

See the section of the Nick Gammon guide starting with "We can disconnect our breadboard from the Uno we used to program the bootloader, and using hook-up wire, connect it to the FTDI cable like this:"
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Strainger

Thank you, DrAzzy.

I apologize - I forgot to mention in my OP that I read a lot of 'it-doesnt-work' posts about USB converters on Google, and did not spend too much time on trying the FTDI converter... Basically all of my post is about using Arduino Uno as uploader.

But, your information is new to me, and I will try it and report back.

Thank you!

Strainger

I spent an hour and more trying to get the FTDI adapter to work, noting that I included the parts you mentioned - pictured on Nick's site.

I end up with the same problem:
"avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x91"

I am now convinced that I am making some idiotic mistake along the way, very possibly the reset during uploading. groundFungus, can you elaborate a bit please?

Thank you both!

groundFungus

When the processor comes out of reset, the boot loader runs.  The boot loader then checks the serial port.  If there is activity on the serial port, the boot loader knows that a new sketch is available for upload and proceeds to load the new sketch code to flash and run the new code.  If there is no serial activity, the boot loader knows to run the code already in flash.  So, upload of a new sketch cannot take place without the target chip going through a reset cycle. 

Strainger

So, upload of a new sketch cannot take place without the target chip going through a reset cycle. 
Ah, thank you for explaining. Will the reset button on the uploader Arduino UNO board serve for this purpose?

And, in the case of the FTDI232 adapter: will I need a push button to reset, although I see people using 100mF capacitors between reset from Arduino and pin1 on chip.

Grrr, I am getting really frustrated. I just cannot see the problem.

Thank you, again, for your time!

groundFungus

DrAzzy explained the auto reset circuit to be used with the FTDI in reply #3.  Once you have a boot loader installed, the FTDI is the easiest way to upload sketces.  Reread reply #3 and try to follow that.  I have used the methods in Nick's post many times to bootload and program Uno and Lilypad stand alone processors. 

Strainger

I managed to upload the blink sketch to the atmega328p on 3 occasions, but randomly. You never know when it is going to upload or not.

But, with the Blink sketch uploaded: when I try to upload a different sketch, it is back to "programmer not responding'.

It takes more than 90 seconds for an upload to fail.

groundFungus

We are operating in the dark here.  I have no idea what your setup is now, what you are doing or how you are doing it.  A schematic drawing of your connections and a description of the steps that you are doing would help get us on the same page.  


Strainger

We are operating in the dark here.
Ugh, I apologize...

From the beginning:
I follow Nick's guide carefully. My wiring is exactly like his on the pictures.
Detecting chip, selecting and burning Lilypad bootloader, verifying... this part works everytime without failure.

Quote
Verifying ...
No errors found.
Done.
Type 'C' when ready to continue with another chip ...
So, I accept that the bootloader is installed correctly. (Please refer my OP if more info needed).

Now I connect my FTDI adapter, as per reply#3, with 0.1uF capacitor to reset.
With Lilypad w/Atmega328P selected, I try to upload Blink sketch. Which fails every time. I tried other boards, like Arduino Pro or Mini.

I reinstalled the FTDI drivers, since it bothered me that the adapter only shows as 'Com11', and not FTDI or someting. Drivers installed correctly, but cannot upload sketch.

Quote
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x56
I have replacement parts for everything, except the 10k pullup resistor that Nick has on pin1 of Atmega chip. It is the only part that I have not swapped out.

After many many tries I went back to Arduino Uno as uploader. I managed to get the Blink sketch uploaded on 3 occasions, but trying a new sketch I get the 'programmer not responding' again.

Wiring:
Quote
Arduino - ATMega
Reset - pin1
0 - pin2
1 - pin3
5V - pin7 and pin22
GND - pin8 and pin20

LED+ to resistor to pin19
LED- to pin22
Thank you again for your patience, I know I am all over the place...



Strainger

Ok, I found a way to get it (sort of) working through the FTDI adapter.

The guy on this site (https://www.youtube.com/watch?v=Jnf-7NToJSI) 'beats' everything into submission:

He has FTDI232 connected to Pro Mini. When he starts uploading the Blink sketch to the Pro Mini, he gets exactly the same error that I do:

Quote
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x91
But, after 'attempt 1 of 10', he simply unplugs the usb from the adapter, plugs it back in, and hits Upload again.... and it works.

So, I tried it, and yes, it works, though not as regularly as with him.

I know he doesn't even have a 0.1uF capacitor in his setup, but the implication for MY scenario must then be that the chip does NOT reset for uploading?

Thank you!

groundFungus

I grabbed a new 328 chip and, using the NIck Gammon chip programmer, bootloaded the chip with the Lilypad bootloader, successfully.   I remove the chip from my programmer and plugged it into a breadboard per the attached circuit.  Upon powering the 328 chip the attached LED blinked at the 1 second on-off (blink is loaded with the bootloader).  I then loaded the blink example sketch and changed the blink delays to 100 so it would be different from the previously installed blink sketch.  I went to the Boards item in the Tools menu and selected "Liliypad Arduino".  Then Tools, again, and made sure that the processor was "ATmega328".  Back to the tools menu to make sure that the right serial port is being used.  My adapter just reads "COM3".  Programmer is "AVR ISP" although that probably doesn't matter.  Clicked the upload arrow and the modified blink sketch compiled and uploaded successfully with no intervention on my part.  The LED blinks with much shorter times, as expected.

If you follow the above and the circuit is correct, I am at a loss as to why your setup does not work.



Strainger

groundFungus, thank you for your time and patience!

Using this plug/unplug method, I now get steady uploads. I believe my wiring correlates with yours, which makes me wonder about that 10K resistor - it is very old and the colours are so faded that I am not confident that it is  indeed 10K (don't know how precise this needs to be?). I live away from civilization, so it will take a bit of time to get replacements.

Anyway, I am on my feet again, and hopefully this brings me to the last stretch of a project that took more than 3 years, a security network consisting of sentry guns with PIR and radar, and some other gimmicks :)

Thank you very much...

Go Up