Author Topic: Programming an external ATmega168 with an Arduino Duemilanove  (Read 16328 times)

0 Members and 1 Guest are viewing this topic.

Offline Randall W. Lott

  • Regular Contributor
  • *
  • Posts: 180
  • Country: us
First of all; I'd like to apologize if there has been a topic on this already.

My goal is to program the QFP ATmega168 that has been integrated into my product.

I have a standard 6-pin ICSP connector on the rear of my housing that connects to the following pins on the ATmega168:

4,6,18:  +5VDC
17:         SCK
16:         MISO
15:         MOSI
29:         RESET

I also have an Arduino Duemilanove with an ATmega328.

What do I need to do to program the blank ATmega168 and start uploading sketches to my product?

Thank you kindly.
- Randy
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 4957
  • Country: de
  • A qualified hobbyist ;)
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #1 on: July 19, 2012, 08:20:42 pm »
Hi!

Please see http://arduino.cc/en/Tutorial/ArduinoISP.

Cheers
 madires
 

Offline Randall W. Lott

  • Regular Contributor
  • *
  • Posts: 180
  • Country: us
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #2 on: July 19, 2012, 09:33:45 pm »
I followed the tutorial here: http://arduino.cc/en/Tutorial/ArduinoISP

I get this error:

avrdude: stk500_getsync(): not in sync: resp=0x00
- Randy
 

Offline Chet T16

  • Frequent Contributor
  • **
  • Posts: 522
  • Country: ie
    • Retro-Renault
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #3 on: July 19, 2012, 11:36:26 pm »
Is this after uploading the arduinoISP sktch or when trying to upload it?
Chet
Paid Electron Wrestler
 

Offline GabYoung92

  • Regular Contributor
  • *
  • Posts: 136
  • Country: au
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #4 on: July 19, 2012, 11:53:38 pm »
I followed the tutorial here: http://arduino.cc/en/Tutorial/ArduinoISP

I get this error:

avrdude: stk500_getsync(): not in sync: resp=0x00

I've been having issues also programming a chip but,

You need up upload the arduinoISP sketch to the arduino. 
Connect up the arduino to the external chip (there's instructions in the header of the sketch). 
Then you need to change the board in the arduinoIDE under tools to match your chip. 
And it's best to check what oscillator it's going to use by the fuses.
Then it should just be an upload.
 

Offline Randall W. Lott

  • Regular Contributor
  • *
  • Posts: 180
  • Country: us
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #5 on: July 20, 2012, 12:14:16 am »
Here is what I did:

  • Opened ArduinoISP sketch under Examples.
  • Chose Arduino Duemilanove w/ ATmega328.
  • Uploaded sketch.  This was successful.
  • Wired the ICSP from my PCB, containing the blank ATmega168, to pins 10-13 on the Arduino.
  • Selected "Arduino as ISP".
  • Chose Arduino Pro under "boards".
  • Attempted to Burn Bootloader.
  • Got the previously mentioned error.

Thank you for the help!
- Randy
 

Offline GabYoung92

  • Regular Contributor
  • *
  • Posts: 136
  • Country: au
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #6 on: July 20, 2012, 12:21:48 am »
That's what I would have done :P

I was having a similar issue caused by the baud rate specified in the boards.txt file.

For example using
9600baud gave an out of sync error
19200baud worked but my chip wouldn't respond (An issue I think caused by the clock of the chip)
38400baud gave an out of sync error.

I would suggest using a different baud rate.
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1306
  • Country: 00
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #7 on: July 20, 2012, 01:15:11 am »
If you use that sketch be sure to fix the bug mentioned here.  Otherwise you can fry both the target MCU as well as your Arduino MCU.
 

Offline Randall W. Lott

  • Regular Contributor
  • *
  • Posts: 180
  • Country: us
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #8 on: July 20, 2012, 09:34:22 am »
Thank you all very much.  I will try this today and I'll report back.
- Randy
 

Offline Randall W. Lott

  • Regular Contributor
  • *
  • Posts: 180
  • Country: us
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #9 on: July 21, 2012, 02:21:41 am »
My ATmega168 is still not working after changing the ISP sketch file and adding a custom 8MHz ATmega168 entry in the Board.txt file.  I'm getting:

In file included from SerialDisplay.cpp:42:

C:\Users\Randy\Desktop\Arduino\Install\hardware\arduino\cores\arduino/Arduino.h:212:26: error: pins_arduino.h: No such file or directory


Is it possible to upload sketches to an external ATmega168 with just the SPI bus?  I'm reading that I need the RX/TX pins to communicate via USB (FTDI interface).  My PCB is already designed and I have no header for these extra pins.

This is becoming pretty frustrating.  I thought it would be a relatively easy task.  I guess Dave had similar issues, but I can't find where he explained his processes and solutions.

I have much of my Arudino source code written.  I'm going to love when I can actually send it off to my micro!
- Randy
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 4957
  • Country: de
  • A qualified hobbyist ;)
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #10 on: July 21, 2012, 12:27:44 pm »
My ATmega168 is still not working after changing the ISP sketch file and adding a custom 8MHz ATmega168 entry in the Board.txt file.  I'm getting:

In file included from SerialDisplay.cpp:42:

C:\Users\Randy\Desktop\Arduino\Install\hardware\arduino\cores\arduino/Arduino.h:212:26: error: pins_arduino.h: No such file or directory


That file could be missing or not found because it's not in the search path. Recently I upgraded to 1.0.1 and had to update some #include statements because the name of a major header file changed.

Quote
Is it possible to upload sketches to an external ATmega168 with just the SPI bus?  I'm reading that I need the RX/TX pins to communicate via USB (FTDI interface).  My PCB is already designed and I have no header for these extra pins.

The ATmega has a serial and parallel interface for flashing. The serial one is simply the SPI bus + Vpp, Gnd and Reset (like the ICSP of the arduino). If you got a Bus Pirate you could also use it as an ISP programmer with avr-dude.
 

Offline shebu18

  • Frequent Contributor
  • **
  • Posts: 309
  • Country: ro
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #11 on: July 21, 2012, 06:42:29 pm »
I have not read the hole topic but out of sync is most of the time caused by not haveing a capacitator in series with the reset line. Look at the arduino scematic., close at the dtr line from the ftdi to the atmega reset pin. If this is ok or hase been mentioned please ignore this post.:)

Sent from my GT-I5800 using Tapatalk
 

Offline Randall W. Lott

  • Regular Contributor
  • *
  • Posts: 180
  • Country: us
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #12 on: July 21, 2012, 11:36:37 pm »
I've come back with more information.  Upon upgrading to 1.01, I receive this code when I try to burn the bootloader:

Code: [Select]
C:\Users\Randy\Desktop\Arduino 1.01\hardware/tools/avr/bin/avrdude -CC:\Users\Randy\Desktop\Arduino 1.01\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega168 -cstk500v1 -P\\.\COM4 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0x07:m -Uhfuse:w:0xD9:m -Ulfuse:w:0xE2:m

avrdude: 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:\Users\Randy\Desktop\Arduino 1.01\hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : \\.\COM4
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
         AVR Part                      : ATMEGA168
         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    20     4    0 no        512    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     16384  128    128  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 : STK500
         Description     : Atmel STK500 Version 1.x firmware
avrdude: Send: A [41] . [80]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [02]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [81]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [01]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [82]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [12]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [98]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
avrdude: Send: A [41] . [84]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [85]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [86]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [87]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [89]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

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

Reading | avrdude: Send: V [56] 0 [30] . [00] . [00] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: V [56] 0 [30] . [00] . [01] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
################avrdude: Send: V [56] 0 [30] . [00] . [02] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
################################## | 100% 0.07s

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

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

avrdude done.  Thank you.

I honestly have no idea what it means or if it's even communicating.
- Randy
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1306
  • Country: 00
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #13 on: July 22, 2012, 06:26:22 am »
It means that avrdude is talking to the programmer (the Arduino firmware) but the programmer isn't talking to the target MCU.

The target MCU needs to be powered (same voltage as the programmer since I'm sure you don't have level converters) and needs to have a common GND with the programmer.  Make sure all the ISP-related pins (SCK, MISO, MOSI and RESET#) are hooked-up properly.

Check to see that RESET is being pulled low by the programmer.  Check SCK and MOSI for activity.

You should change your command line to NOT program the fuses and instead do something a little less dangerous until you get everything working.  Something like this, perhaps:

Code: [Select]
avrdude -CC:\Users\Randy\Desktop\Arduino 1.01\hardware/tools/avr/etc/avrdude.conf -patmega168 -cstk500v1 -P\\.\COM4 -b19200 -t

This will put you in terminal mode.  (Once it communicates successfully with the MCU.)  Once in terminal mode you can inspect memory and whatnot to see if everything seems to be working.
« Last Edit: July 22, 2012, 08:37:00 am by TerminalJack505 »
 

Offline Randall W. Lott

  • Regular Contributor
  • *
  • Posts: 180
  • Country: us
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #14 on: July 22, 2012, 09:12:03 pm »
Do you guys suggest using any passive components?

The guide shows a 10k Ohm resistor across SPI reset and 5V.

I've also seen people mention to use a capacitor.  I'll be going to my house today, where my components are, so I am wondering if I need to grab some.

Thanks for the continued support.
- Randy
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1306
  • Country: 00
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #15 on: July 22, 2012, 09:23:41 pm »
I've always pulled-up RESET# with a 10k resistor and put a 10nF bypass cap on it as well--as recommended by this Atmel app note.
 

Offline Randall W. Lott

  • Regular Contributor
  • *
  • Posts: 180
  • Country: us
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #16 on: July 23, 2012, 05:20:41 am »
Rather strangely, I'm getting an error after typing in the suggested codes in command prompt.

Code: [Select]
C:\Users\Randy>avrdude -CC:\Users\Randy\Desktop\Arduino 1.01\hardware/tools/avr
/etc/avrdude.conf -patmega168 -cstk500v1 -P\\.\COM5 -b19200 -t
error at C:\Users\Randy\Desktop\Arduino 1.01\hardware/tools/avr/etc/avrdude.con
f:332 unrecognized character: "w"

I'm not sure what to think of it.  I freshly installed the Arduino IDE and WinAVR literally 5 minutes before attempting this, although "Google" told me that it could be a corrupted installation of the Arduino IDE.
- Randy
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1306
  • Country: 00
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #17 on: July 23, 2012, 06:59:17 am »
I bet the WinAVR version of avrdude is what is in your path and the configuration file you specified in the Arduino folder is from an older version of avrdude.  Try just leaving that -C option out.

Code: [Select]
avrdude -patmega168 -cstk500v1 -P\\.\COM5 -b19200 -t
 

Offline Randall W. Lott

  • Regular Contributor
  • *
  • Posts: 180
  • Country: us
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #18 on: July 23, 2012, 08:14:06 am »
I'm getting:

Code: [Select]
C:\Users\Randy>avrdude -v -v -v -v -patmega168 -cstk500v1 -P\\.\COM5 -b19200 -t

avrdude: Version 5.11-Patch#7610, compiled on Aug 31 2011 at 08:02:19
         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.conf"


         Using Port                    : \\.\COM5
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
         AVR Part                      : ATMEGA168
         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  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           eeprom        65    20     4    0 no        512    4      0  3600  36
00 0xff 0xff
                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           flash         65     6   128    0 yes     16384  128    128  4500  45
00 0xff 0xff
                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           lfuse          0     0     0    0 no          1    0      0  4500  45
00 0x00 0x00
                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           hfuse          0     0     0    0 no          1    0      0  4500  45
00 0x00 0x00
                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           efuse          0     0     0    0 no          1    0      0  4500  45
00 0x00 0x00
                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           lock           0     0     0    0 no          1    0      0  4500  45
00 0x00 0x00
                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   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  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           signature      0     0     0    0 no          3    0      0     0
 0 0x00 0x00

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

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

Reading |                                                    | 0% 0.00savrdude:
Send: V [56] 0 [30] . [00] . [00] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: V [56] 0 [30] . [00] . [01] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
Reading | #################                                  | 33% 0.13savrdude:
 Send: V [56] 0 [30] . [00] . [02] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
Reading | ################################################## | 100% 0.20s

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

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

avrdude done.  Thank you.

I've done about a dozen Google searches for device signature errors.  Someone mentioned that by lowering the SPI clock, it worked.  I have no idea what I should try now.

Thanks again.
- Randy
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1306
  • Country: 00
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #19 on: July 23, 2012, 08:26:29 am »
If you're using the latest version of that sketch then the SPI clock is running as slow as it can run unless you change the Arduino's system clock speed. 

If you're comfortable with changing the clock to the internal RC then that is one way to slow the SPI clock down.  This involves changing the fuse bits of the MCU on the Arduino board.  If you get things wrong you can wind up bricking your Arduino.
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1306
  • Country: 00
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #20 on: July 23, 2012, 09:15:30 am »
I just did some quick calculations and it looks like the SPI clock speed should be okay.  If the Arduino's clock is 16 Mhz then the SPI clock will be set to 125 kHz.  This is assuming you're using version 0.4 of that sketch and haven't changed the spi_init() function:

Code: [Select]
void spi_init() {
  uint8_t x;
  SPCR = 0x53;
  x=SPSR;
  x=SPDR;
}

If your target MCU is running at 1 Mhz (factory default) then the 125 kHz should work according to the datasheet:

Datasheet, Page 308:

Quote
The minimum low and high periods for the serial clock (SCK) input are defined as follows:

Low: 2 CPU clock cycles for fck < 12 Mhz, 3 CPU clock cycles for fck >= 12 Mhz
High:  2 CPU clock cycles for fck < 12 Mhz, 3 CPU clock cycles for fck >= 12 Mhz

Which is saying the SCK low period needs to be at least 2 us and the high period needs to be at least 2 us.  Each of these should be 4 us.  You might hook up the scope to SCK and double check, however. 

In other words, I don't think the SPI clock is the problem.  Can you provide a simple schematic of how you have the Arduino wired-up to the target board?
 

Offline Randall W. Lott

  • Regular Contributor
  • *
  • Posts: 180
  • Country: us
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #21 on: July 23, 2012, 09:51:53 am »
I have a standard ICSP 2x3 connector on the rear of my enclosure.  This ties to my SPI bus, which is in a master/slave setup.

My ATmega168's reset line is wired to the connector, whereas each slave devices' "SS" will use a programmed pin on the micro.

I used the suggested resistors in the recommended locations.

Every power pin in my entire design has a decoupling capacitor.  My microcontroller has a 1uF and .1uF capacitor on each power pin for reassurance.

I'm operating at 5V and my voltage regulators can handle more than my requirements.  The rails are fine under load.

There is an 8MHz oscillator for the micro, which was implemented based on their recommendations.  Of course, this is disabled until I can change the fuse to enable it.

I have to be doing something wrong.  I can't even burn the bootloader in the Arduino IDE or in AVRdude (cmd).


Is it worth getting a USB programmer for $20?  I'm getting a little frustrated with this process.  I know it'll be worth the effort later, though.  I have an oscilloscope, but I don't know what the signals should look like at what times during the programming.
- Randy
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1306
  • Country: 00
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #22 on: July 23, 2012, 12:00:47 pm »
I don't know what the problem might be but someone else had problems trying to use that sketch as well so it might just be a bad sketch.  I know they broke a lot of the old sketches when they went to version 1.0 too so that might be the problem.

So long as you have something like the attached schematic for the programming then I would give up and get a real programmer.
 

Offline madworm

  • Frequent Contributor
  • **
  • Posts: 373
  • Country: de
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #23 on: July 23, 2012, 02:58:43 pm »
If you don't value your time, then by all means don't spend the huge amount of 20$ on a programmer that works.
 

Offline MickM

  • Regular Contributor
  • *
  • Posts: 100
Re: Programming an external ATmega168 with an Arduino Duemilanove
« Reply #24 on: July 23, 2012, 09:33:28 pm »
USBTiny complete kit:
https://www.adafruit.com/products/46

USBTiny preprogrammed chip only:
https://www.adafruit.com/products/54
You can then build your own.

I bought the kit, works fine for mega328

Mick M
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf