Use Mega 2560 to program a Atmel168A-PU

Hi.

I'm new to this forum, so I'm sorry if this is in the wrong section.

I have an Ardiuno mega 2560, and a few Atme168A-PU, and I'd like to use the mega to program the 168's.

I've Googled around, seen Youtube videos and read on the arduino site. Arduino to breadboard. Aamongst other.

But I can't seem to get it to work. My workstation is a Ubuntu 14.04, with Arduino 1.0.5. One of the things I've done is to program the mega 2560 with the File-Example-ArduinoISP sketch. Mounted LEDs on the breadborad. The heartbeat is pulsing. So everything seems to be fine.

Then I've made a small sketch that should blink a LED on digital pin 13. Then I've used File-Upload Using Programmer. I get the programmer is not responding and not in sync: resp=0x00 message all the time.

What am I doing wrong.

  • nerdegutta

Did you remember to disable AutoReset on the Mega?

Did you wire to the MEGA SPI pins (51-53) instead of the UNO SPI pins (11-13)?

Disable the Autoreset? Hm... Where is that setting? I've put a 10uF cap on reset to gnd.

I've tried the 51-53,the 11-13 and the isp pin header. No luck. :-(

  • nerdegutta

nerdegutta: I've tried the 51-53,the 11-13 and the isp pin header. No luck. :-(

The cap will take care of auto-reset so that's fine. Using the ICSP header is the best bet since it is the only choice that works on UNO, Mega, and Leonardo. Unlike serial where you connect RX to TX and TX to RX you have to connect MISO to MISO and MOSI to MOSI. You should be using 5 of the ICMP header pins (MOSI, MISO, SCLK, GND, and VCC) and Pin 10. What board type do you use when uploading to your ATmega168A? (You called it an Atme168A-PU)

Have you done a "Burn Bootloader" on the chip to set the configuration fuses? Does it have a crystal connected?

I’m trying to program a chip on a breadboard. The Atmega168A-PU. I’ve connected Pin 8 & 22 to GND rail. Pin 7, 20 & 21 is tied to +5v rail. Pin 1 is tied to +5v with a 10K pull-up resistor. I’ve also tried a 120R resistor. Pin 9 & 10 have a 8MHz crystal between them, and they are tied to GND with 18pF ceramic capacitor. I’ve tried 16MHz and 22pF caps, but to no luck.

From the ISP header: MISO to MISO, MOSI to MOSI, GND to GND rail, VCC to VCC rail. RST to pin 1.

I’ve not tried to connect pin 10 to pin 1, yet…

I’ve not been able to burn the bootloader.

Here’s my breadboard:

  • nerdegutta

I see you have a jumper over the midpoint break in the upper power rail and the lower ground rail but you are also using the upper ground rail and lower power rail. Add two more jumpers for those midpoint breaks.

"I've not tried to connect pin 10 to pin 1, yet..." ArduinoISP certainly won't work if it can't use Pin 10 to hold the target chip in reset.

What board type do you use when uploading to your ATmega168A? Still waiting for an answer to that.

johnwasser: I see you have a jumper over the midpoint break in the upper power rail and the lower ground rail but you are also using the upper ground rail and lower power rail. Add two more jumpers for those midpoint breaks.

Good eye!

Jumpers are added!

johnwasser: "I've not tried to connect pin 10 to pin 1, yet..." ArduinoISP certainly won't work if it can't use Pin 10 to hold the target chip in reset.

I was using, or at least I thought I could use the reset pin on the ICSP header.

johnwasser:

What board type do you use when uploading to your ATmega168A? Still waiting for an answer to that.

Arduino Mega 2560.

|500x375

I'm using the ICSP header which is left from the reset button.

Thank you for reading, but after adding jumpers and connecting Mega2560 pin 10 to Atmega168 pin 1 I still get nothing...

  • nerdegutta

Not what I meant.

What board type do you set just before you select Tools->Burn Bootloader? You can't leave it set to Tools->Board->Arduino MEGA because the ATmega168A is not an ATmega2560. It can't accept an ATmega2560 bootloader. You could try:

Tools->Board->Arduino Duemilanove or Diecimila
Tools->Processor->ATmega168
Tools->Port->(serial port for your Arduino MEGA 2560 running ArduinoISP)
Tools->Programmer->Arduino as ISP
Tools->Burn Bootloader

I suspect that even is all the wiring is correct you will get a signature error since I think the ATmega168A has a different signature than the ATmega168.

Oh... I see.

I got a pulsing heartbeat LED, so I recon the Arduino as ISP is working.

I've tried all the different boards in the Tools -> Board list. The programming board (Mega 2560) is connected to the computer with USB. Tools -> Serial Port -> /dev/ttyACM2. The Tools -> Programmer -> Arduino as ISP is bullet out.

I do not have a Tools -> Processor option.

I'm on Ubuntu 14.04 32-bit with Arduino 1:1.0.5+dfsg2-2 IDE.

johnwasser: I suspect that even is all the wiring is correct you will get a signature error since I think the ATmega168A has a different signature than the ATmega168.

That would be just my luck!

  • nerdegutta

johnwasser: You could try:

Tools->Processor->ATmega168

I installed Arduino 1.6.2 on a old WIN XP computer. But to no luck. I get the same errors.

avrdude: stk500_recv(): programmer is not responding

It really starts to frustrate me. Will I not be able to program my Atmega168A-PU at all? Or put another way: What does it take?

I feel I've tried nearly everything.

I saw somewhere someone editing their board.txt file, to suit their needs. Is it possible for me to do that? It would be awesome if I could have an entry saying: Minimum Atmega168A-PU on breadboard.

  • nerdegutta

Signature bytes ATmega168 0x1E 0x94 0x06 ATmega168A 0x1E 0x94 0x06

ATmega168P 0x1E 0x94 0x0B ATmega168PA 0x1E 0x94 0x0B

One way is to edit avrdude.conf to put 168A signature bytes in place of 168P signature bytes, then try again. Burn bootloader. Serial downloads should respond normally after that. Put signature bytes back after that.

Alternately, create new section boards.txt, create new board type using 168A. Copy 168P section in avrdude.conf, paste in as 168A section with signature bytes and 168A name. Then select the new board type for programming.

Uhm... So I opened the avrdude.conf file. Search for the ATmega168, and found it. Edited the line with the signature, started Arduino again, tried different boards, but I'm not able to burn the bootloader nor the sketch. (blink a LED on pin 13).

When it comes to option 2, I do need some help on the board.txt - file sections.

  • nerdegutta
avrdude: stk500_recv(): programmer is not responding

You seem to be having trouble communication with the ArduinoISP sketch. The 10 uF capacitor connected between Reset and Ground on the MEGA should do the trick. Does the RX LED on the MEGA flash a few times when you try to do an upload? Does the TX LED also flash?

johnwasser: avrdude: stk500_recv(): programmer is not responding

You seem to be having trouble communication with the ArduinoISP sketch. The 10 uF capacitor connected between Reset and Ground on the MEGA should do the trick. Does the RX LED on the MEGA flash a few times when you try to do an upload? Does the TX LED also flash?

When I connect the Mega board, with the 10uF cap in place, it takes a while then the heartbeat led flickers a bit, and then it starts to fade in/out.

When I then load my sketch, and click File->Upload Using Programmer, the RX and TX blinks a few times, and then they stay off, the heartbeat led stops fading, and I get the

programmer is not responding

message.

I've read a bit about the content in the board.txt file, and I've come up with this:

atmega168a.name=Minimum ATmega168A-PU on a breadboard

atmega168a.build.mcu=atmega168a
atmega168a.build.f_cpu=8000000L
atmege168a.build.core=arduino:arduino

atmege168a.upload.protocol=stk500
atmege168a.upload.speed=19200
atmege168a.upload.disable_flushing=true
atmege168a.upload.maximum_size=14336

atmege168a.bootloader.low_fuses=0xFF
atmege168a.bootloader.high_fuses=0xDA
atmege168a.bootloader.extended_fuses=0x05
atmege168a.bootloader.path=arduino:atmega
atmege168a.bootloader.file=ATmegaBOOT_168_atmega328.hex
atmege168a.bootloader.unlock_bits=0x3F
atmege168a.bootloader.lock_bits=0x0F

When I select this entry in Tools->Board I get an error message teklling me that there is no board selected.

What's up with that?

  • nerdegutta

Hmm, you do seem pretty close. Keep at it. If I had more chip types on hand I could try it out for you.

Well, I suppose I could try the compiling part without chips too.

Oh - you might also need a /variants folder with /atmega168a and pins_arduino.h from a 168 board type in it.

To get the right bootloader I would start with the an existing 8MHz ATmega168 model (like the Pro Mini) and modify from there:

atmega168a.name=[color=#222222]ATmega168A-PU on a breadboard (8 Mhz)[/color]

atmega168a.upload.tool=avrdude
atmega168a.upload.protocol=arduino

atmega168a.bootloader.tool=avrdude
atmega168a.bootloader.unlock_bits=0x3F
atmega168a.bootloader.lock_bits=0x0F

atmega168a.build.board=AVR_PRO
atmega168a.build.core=arduino:arduino
atmega168a.build.variant=arduino:standard

atmega168a.upload.maximum_size=14336
atmega168a.upload.maximum_data_size=1024
atmega168a.upload.speed=19200

atmega168a.bootloader.low_fuses=0xc6
atmega168a.bootloader.high_fuses=0xdd
atmega168a.bootloader.extended_fuses=0x00
atmega168a.bootloader.file=atmega/ATmegaBOOT_168_pro_8MHz.hex

atmega168a.build.mcu=atmega168a
atmega168a.build.f_cpu=8000000L

CrossRoads: Well, I suppose I could try the compiling part without chips too.

That would be awesome!

CrossRoads: Oh - you might also need a /variants folder with /atmega168a and pins_arduino.h from a 168 board type in it.

Where do I find the pins_arduino.h file?

johnwasser: To get the right bootloader I would start with the an existing 8MHz ATmega168 model (like the Pro Mini) and modify from there:

atmega168a.name=[color=#222222]ATmega168A-PU on a breadboard (8 Mhz)[/color]

atmega168a.upload.tool=avrdude atmega168a.upload.protocol=arduino

atmega168a.bootloader.tool=avrdude atmega168a.bootloader.unlock_bits=0x3F atmega168a.bootloader.lock_bits=0x0F

atmega168a.build.board=AVR_PRO atmega168a.build.core=arduino:arduino atmega168a.build.variant=arduino:standard

atmega168a.upload.maximum_size=14336 atmega168a.upload.maximum_data_size=1024 atmega168a.upload.speed=19200

atmega168a.bootloader.low_fuses=0xc6 atmega168a.bootloader.high_fuses=0xdd atmega168a.bootloader.extended_fuses=0x00 atmega168a.bootloader.file=atmega/ATmegaBOOT_168_pro_8MHz.hex

atmega168a.build.mcu=atmega168a atmega168a.build.f_cpu=8000000L

Nice! I'll try that!

Thanks!

  • nerdegutta