Atmega 1280 as ISP - Imposibru !

Hi guys, i have searched everywhere i could this is my last place to try to get it working.

I have the arduino mega with the atmega1280 and i want to program a chip i have atmega328 (not the 328p).

For that matter i uploaded to my arduino the example of the arduinoISP and then connected:
Pins Arduino - 328 chip
53 1 (reset)
52 19(SCK)
51 17(MOSI) I even switched MOSI with the MISO thinking i could had them wrong, but no.
50 18(MISO)

The sketched uploaded, some of the leds flashed, because i connected those 3 leds too.

I'm only using the chip with no cristal, its the 328 - 20pu so i gess 20Mhz crystal inside ?
I even added a 10kohm resistor from the 328 pin 1 (reset) to the 5 volt. ( tried with it on and off ).

I choose arduino as isp in the programmers list. I even downloaded this file for the boards.txt

##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=stk500
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino

But still does not work, i typed CMD, ran as administrator, browsed to avrdude and typed:

avrdude.exe -p m328 -b 19200 -P com7 -c avrisp

And i get Device signature 0xfffffff sometimes 0x0000000
yikes! invalid device signature.

The green "7: Programming - In communication with the slave" flashed a bit and then the error light flashes.

The heart beat led keeps on fadding in and out when i do nothing.

I don't know what to do anymore, i have been searching for almost 5hours straight i tried many things, im currently using the arduino 1.0 software but i tried with 022.

But anyway the avrdude outputs that, i think wrong, signature and so, unless it gets it right it might not have to do with the arduino software in the first place.

I'm only using the chip with no cristal, its the 328 - 20pu so i gess 20Mhz crystal inside ?

No. The internal oscillator is 8 MHz. From the factory, the oscillator frequency is divided by 8 giving a CPU clock of 1 MHz.

The "20" indicates the maximum frequency. You have to provide an external clock source (like a crystal or resonator) to reach that frequency.

I even added a 10kohm resistor from the 328 pin 1 (reset) to the 5 volt. ( tried with it on and off ).

Including a 10K pullup resistor on RESET is a good choice.

avrdude.exe -p m328 -b 19200 -P com7 -c avrisp

Even though it should not make any difference, I vaguely recall that "avrisp" gave me problems. Try "arduino" or "stk500"...
avrdude.exe -p m328 -b 19200 -P com7 -c arduino

I suggest that you successfully communicate with the ATmega328 (the "target") using avrdude before trying to upload through the Arduino IDE. When it works, something like this should be the results...

C:\ >avrdude -p t13 -b 250000 -P \\.\COM14 -c arduino

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny13
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9007

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

It would be helpful if you posted the results of running avrdude in "very verbose" mode...

avrdude.exe -p m328 -b 19200 -P com7 -c arduino -v -v -v -v

And i get Device signature 0xfffffff sometimes 0x0000000
yikes! invalid device signature.

In most cases, that indicates the programmer (your Arduino Mega) is not communicating with the target (your ATmega328). The most likely culprit is wiring. The second most likely culprit is that the target is not properly clocked. Did you try to burn a bootloader?

Try running the Optiloader sketch instead

See the video at the end of this thread
http://arduino.cc/forum/index.php/topic,68183.0.html

Optiloader here

Here is the resulte of the "avrdude.exe -p m328p -b 19200 -P com7
-c arduino -v -v -v -v"

I bought a 16mhz clock today i will use it too and see if it was because of not using one... If not i will be left without solution :S

M:\ISEP\arduino-1.0\hardware\tools\avr\bin>avrdude.exe -p m328p -b 19200 -P com7
 -c arduino -v -v -v -v

avrdude.exe: Version 5.11, compiled on Sep  2 2011 at 19:38:36
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2009 Joerg Wunsch

             System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.c
onf"

             Using Port                    : com7
             Using Programmer              : arduino
             Overriding Baud Rate          : 19200
avrdude.exe: Send: 0 [30]   [20]
avrdude.exe: Send: 0 [30]   [20]
avrdude.exe: Send: 0 [30]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [10]
             AVR Part                      : ATMEGA328P
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PC2
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :

                                      Block Poll               Page
          Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW
 MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ -----
 ----- ---------
               eeprom        65     5     4    0 no       1024    4      0  3600
  3600 0xff 0xff
                                      Block Poll               Page
          Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW
 MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ -----
 ----- ---------
               flash         65     6   128    0 yes     32768  128    256  4500
  4500 0xff 0xff
                                      Block Poll               Page
          Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW
 MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ -----
 ----- ---------
               lfuse          0     0     0    0 no          1    0      0  4500
  4500 0x00 0x00
                                      Block Poll               Page
          Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW
 MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ -----
 ----- ---------
               hfuse          0     0     0    0 no          1    0      0  4500
  4500 0x00 0x00
                                      Block Poll               Page
          Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW
 MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ -----
 ----- ---------
               efuse          0     0     0    0 no          1    0      0  4500
  4500 0x00 0x00
                                      Block Poll               Page
          Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW
 MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ -----
 ----- ---------
               lock           0     0     0    0 no          1    0      0  4500
  4500 0x00 0x00
                                      Block Poll               Page
          Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW
 MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ -----
 ----- ---------
               calibration    0     0     0    0 no          1    0      0     0
     0 0x00 0x00
                                      Block Poll               Page
          Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW
 MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ -----
 ----- ---------
               signature      0     0     0    0 no          3    0      0     0
     0 0x00 0x00

             Programmer Type : Arduino
             Description     : Arduino
avrdude.exe: Send: A [41] . [80]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [02]
avrdude.exe: Recv: . [10]
avrdude.exe: Send: A [41] . [81]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [01]
avrdude.exe: Recv: . [10]
avrdude.exe: Send: A [41] . [82]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [12]
avrdude.exe: Recv: . [10]
avrdude.exe: Send: A [41] . [98]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [00]
avrdude.exe: Recv: . [10]
             Hardware Version: 2
             Firmware Version: 1.18
             Topcard         : Unknown
avrdude.exe: Send: A [41] . [84]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [00]
avrdude.exe: Recv: . [10]
avrdude.exe: Send: A [41] . [85]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [00]
avrdude.exe: Recv: . [10]
avrdude.exe: Send: A [41] . [86]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [00]
avrdude.exe: Recv: . [10]
avrdude.exe: Send: A [41] . [87]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [00]
avrdude.exe: Recv: . [10]
avrdude.exe: Send: A [41] . [89]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [00]
avrdude.exe: Recv: . [10]
             Vtarget         : 0.0 V
             Varef           : 0.0 V
             Oscillator      : Off
             SCK period      : 0.1 us

avrdude.exe: Send: A [41] . [81]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [01]
avrdude.exe: Recv: . [10]
avrdude.exe: Send: A [41] . [82]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [12]
avrdude.exe: Recv: . [10]
avrdude.exe: Send: B [42] . [86] . [00] . [00] . [01] . [01] . [01] . [01] . [03
] . [ff] . [ff] . [ff] . [ff] . [00] . [80] . [04] . [00] . [00] . [00] . [80] .
 [00]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [10]
avrdude.exe: Send: E [45] . [05] . [04] . [d7] . [c2] . [00]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [10]
avrdude.exe: Send: P [50]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [10]
avrdude.exe: AVR device initialized and ready to accept instructions

Reading |                                                    | 0% 0.00savrdude.e
xe: Send: u [75]   [20]
avrdude.exe: Recv: . [14] . [00] . [00] . [00] . [10]
Reading | ################################################## | 100% 0.03s

avrdude.exe: Device signature = 0x000000
avrdude.exe: Yikes!  Invalid device signature.
             Double check connections and try again, or use -F to override
             this check.

avrdude.exe: Send: Q [51]   [20]
avrdude.exe: Recv: . [14]
avrdude.exe: Recv: . [10]

avrdude.exe done.  Thank you.


M:\ISEP\arduino-1.0\hardware\tools\avr\bin>

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

it is working now !!! hurray!

It needed the 16Mhz crystal !

I bought 22n capacitors but i figured out it usualy is 22pF but it is working without the capcitors, maybe i can use the 22n capcitors i have?
Shouldn't it work without the crystal? Just the chip alone?

Anyway, now i get the signature of the m328p i will just edit the config file to match the signatures and i will report my progress.

I've already managed to upload the bootloader but since i have an atmega 1280 i cannot remove the chip to program the other one.
Any thoughts ?

Ive used

avrdude.exe -p m328p -b 19200 -P com7 -c arduino -U flash:w:blink.hex

It works on the command line, but i need to go to temporary folder everytime to get the arduino hex file.
On the arduino ide i got arduino as isp choosen for the programmer but it does not work it says avrdude: stk500_getsync(): not in sync: resp=0x00

I think it tries to write in my atmega1280 but since i have de reset disable it does not upload. Maybe i could change the boards.txt file to make it use the same settings as the avrdude?

I bought 22n capacitors but i figured out it usualy is 22pF but it is working without the capcitors, maybe i can use the 22n capcitors i have?

No, 22n are much too large and could prevent the crystal/oscillator circuit from even starting.

Crystals are rated at a particular speed given a particular capacitance, so it won't be running at the proper speed without them. It might not even work reliably. If I understand it correctly (someone please correct me if I'm wrong), the caps actually provide a sort of feedback to keep the oscillations going. You still have a certain amount of capacitance just from the physical properties of the crystal, the leads, your breadboard, wires, and the IC, but not enough. You should really try to get the 22pF caps rather than just leave it as-is.

You can use the internal oscillator (at 8MHz) by changing the fuse byte values. That's a little more advanced, and you have to be careful not to set conditions that would prevent the chip from being able to boot up again. You might want to stick to using the external oscillator for now. The only advantage to using the internal clock is the minimal parts count, and crystals and caps are hardly expensive or difficult to deal with. If you want to give it a try anyway, do some research on the fuse bytes and how to use them properly, then come back to it when you've got a handle on it. But get everything working the easy way first. :slight_smile:

oh, so you say that in order to use the internal clock there some configuration needed first, thats why it didnt work.

But actually that isnt such a great problem, i just wanted to try it without the crystal because i ve seen it could be done.

Anyways i am just stuck with the problem on the arduino software, i can upload using avrdude and arduino protocol but cannot upload using the arduino software :S

Iam using the atmega as a programmer, i can upload the bootloader, i can upload blink example using avrdude with the code i posted before but cannot with the arduino ide

Maybe someone has a diferent configuration that i could use on the arduino IDE

Are you using Arduino 1.0? 0022?

I am using the 1.0 atm

But i do not want to program using the bootloader because i can't remove the atmega1280 from my board, i want to program it directly like when you click to burn the bootloader.

I can do it using the avrdude with -c arduino but i always need to search for the hex in temp folder :S

marcosmoura:
I am using the 1.0 atm

But i do not want to program using the bootloader because i can't remove the atmega1280 from my board, i want to program it directly like when you click to burn the bootloader.

I can do it using the avrdude with -c arduino but i always need to search for the hex in temp folder :S

If using IDE 1.0 then steps would be:

  1. In tools/programmer, select arduino as ISP
  2. under File menu, select upload using programmer

Is that the procedure you tried?

Yep i tried those, it only works if i choose burn the bootloader,

But if i try to upload some code, maybe the blink example it tries to connect to my arduino instead of the atmega328 chip i got.

If i use the avrdude as i said before it works :S