Programming an external ATmega168 with an Arduino Duemilanove - Page 1
Forum section: electronics / general

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: July 19, 2012, 08:08:08 pm
content: 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: +5VDC17: SCK16: MISO15: MOSI29: RESETI 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.

author: madires
author_rank: Super Contributor
timestamp: July 19, 2012, 08:20:42 pm
content: Hi!Please seehttp://arduino.cc/en/Tutorial/ArduinoISP.Cheersmadires

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: July 19, 2012, 09:33:45 pm
content: I followed the tutorial here:http://arduino.cc/en/Tutorial/ArduinoISPI get this error:avrdude: stk500_getsync(): not in sync: resp=0x00

author: Chet T16
author_rank: Frequent Contributor
timestamp: July 19, 2012, 11:36:26 pm
content: Is this after uploading the arduinoISP sktch or when trying to upload it?

author: GabYoung92
author_rank: Regular Contributor
timestamp: July 19, 2012, 11:53:38 pm
content: Quote from: Randall W. Lott on July 19, 2012, 09:33:45 pmI'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.

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: July 20, 2012, 12:14:16 am
content: 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!

author: GabYoung92
author_rank: Regular Contributor
timestamp: July 20, 2012, 12:21:48 am
content: That's what I would have doneI was having a similar issue caused by the baud rate specified in the boards.txt file.For example using9600baud gave an out of sync error19200baud 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.

author: TerminalJack505
author_rank: Super Contributor
timestamp: July 20, 2012, 01:15:11 am
content: If you use that sketch be sure to fix the bug mentionedhere. Otherwise you can fry both the target MCU as well as your Arduino MCU.

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: July 20, 2012, 09:34:22 am
content: Thank you all very much. I will try this today and I'll report back.

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: July 21, 2012, 02:21:41 am
content: 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 directoryIs 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!

author: madires
author_rank: Super Contributor
timestamp: July 21, 2012, 12:27:44 pm
content: Quote from: Randall W. Lott on July 21, 2012, 02:21:41 amThat 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.QuoteThe 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.

author: shebu18
author_rank: Frequent Contributor
timestamp: July 21, 2012, 06:42:29 pm
content: 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

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: July 21, 2012, 11:36:37 pm
content: I've come back with more information. Upon upgrading to 1.01, I receive this code when I try to burn the bootloader:Code: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:mavrdude: Version 5.11, compiled on Sep 2 2011 at 19:38:36Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/Copyright (c) 2007-2009 Joerg WunschSystem wide configuration file is "C:\Users\Randy\Desktop\Arduino 1.01\hardware/tools/avr/etc/avrdude.conf"Using Port : \\.\COM4Using Programmer : stk500v1Overriding Baud Rate : 19200avrdude: Send: 0  avrdude: Send: 0  avrdude: Send: 0  avrdude: Recv: . avrdude: Recv: . AVR Part : ATMEGA168Chip Erase delay : 9000 usPAGEL : PD7BS2 : PC2RESET disposition : dedicatedRETRY pulse : SCKserial program mode : yesparallel program mode : yesTimeout : 200StabDelay : 100CmdexeDelay : 25SyncLoops : 32ByteDelay : 0PollIndex : 3PollValue : 0x53Memory Detail :Block Poll Page PolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------eeprom 65 20 4 0 no 512 4 0 3600 3600 0xff 0xffBlock Poll Page PolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------flash 65 6 128 0 yes 16384 128 128 4500 4500 0xff 0xffBlock Poll Page PolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00Block Poll Page PolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00Block Poll Page PolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00Block Poll Page PolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00Block Poll Page PolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00Block Poll Page PolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00Programmer Type : STK500Description : Atmel STK500 Version 1.x firmwareavrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . Hardware Version: 2Firmware Version: 1.18Topcard : Unknownavrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . Vtarget : 0.0 VVaref : 0.0 VOscillator : OffSCK period : 0.1 usavrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: B  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  @  .  avrdude: Recv: . avrdude: Recv: . avrdude: Send: E  .  .  .  .  .  avrdude: Recv: . avrdude: Recv: . avrdude: Send: P  avrdude: Recv: . avrdude: Recv: . avrdude: AVR device initialized and ready to accept instructionsReading | avrdude: Send: V  0  .  .  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: V  0  .  .  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . ################avrdude: Send: V  0  .  .  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . ################################## | 100% 0.07savrdude: Device signature = 0x000000avrdude: Yikes! Invalid device signature.Double check connections and try again, or use -F to overridethis check.avrdude: Send: Q  avrdude: Recv: . avrdude: Recv: . avrdude done. Thank you.I honestly have no idea what it means or if it's even communicating.

author: TerminalJack505
author_rank: Super Contributor
timestamp: July 22, 2012, 06:26:22 am
content: 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:avrdude -CC:\Users\Randy\Desktop\Arduino 1.01\hardware/tools/avr/etc/avrdude.conf -patmega168 -cstk500v1 -P\\.\COM4 -b19200 -tThis 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.

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: July 22, 2012, 09:12:03 pm
content: 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.

author: TerminalJack505
author_rank: Super Contributor
timestamp: July 22, 2012, 09:23:41 pm
content: I've always pulled-up RESET# with a 10k resistor and put a 10nF bypass cap on it as well--as recommended bythisAtmel app note.

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: July 23, 2012, 05:20:41 am
content: Rather strangely, I'm getting an error after typing in the suggested codes in command prompt.Code:C:\Users\Randy>avrdude -CC:\Users\Randy\Desktop\Arduino 1.01\hardware/tools/avr/etc/avrdude.conf -patmega168 -cstk500v1 -P\\.\COM5 -b19200 -terror at C:\Users\Randy\Desktop\Arduino 1.01\hardware/tools/avr/etc/avrdude.conf: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.

author: TerminalJack505
author_rank: Super Contributor
timestamp: July 23, 2012, 06:59:17 am
content: 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:avrdude -patmega168 -cstk500v1 -P\\.\COM5 -b19200 -t

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: July 23, 2012, 08:14:06 am
content: I'm getting:Code:C:\Users\Randy>avrdude -v -v -v -v -patmega168 -cstk500v1 -P\\.\COM5 -b19200 -tavrdude: Version 5.11-Patch#7610, compiled on Aug 31 2011 at 08:02:19Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/Copyright (c) 2007-2009 Joerg WunschSystem wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"Using Port : \\.\COM5Using Programmer : stk500v1Overriding Baud Rate : 19200avrdude: Send: 0  avrdude: Send: 0  avrdude: Send: 0  avrdude: Recv: . avrdude: Recv: . AVR Part : ATMEGA168Chip Erase delay : 9000 usPAGEL : PD7BS2 : PC2RESET disposition : dedicatedRETRY pulse : SCKserial program mode : yesparallel program mode : yesTimeout : 200StabDelay : 100CmdexeDelay : 25SyncLoops : 32ByteDelay : 0PollIndex : 3PollValue : 0x53Memory Detail :Block Poll PagePolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------eeprom 65 20 4 0 no 512 4 0 3600 3600 0xff 0xffBlock Poll PagePolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------flash 65 6 128 0 yes 16384 128 128 4500 4500 0xff 0xffBlock Poll PagePolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00Block Poll PagePolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00Block Poll PagePolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00Block Poll PagePolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00Block Poll PagePolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------calibration 0 0 0 0 no 1 0 0 00 0x00 0x00Block Poll PagePolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------signature 0 0 0 0 no 3 0 0 00 0x00 0x00Programmer Type : STK500Description : Atmel STK500 Version 1.x firmwareavrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . Hardware Version: 2Firmware Version: 1.18Topcard : Unknownavrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . Vtarget : 0.0 VVaref : 0.0 VOscillator : OffSCK period : 0.1 usavrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: A  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: B  .  .  .  .  .  .  .  .  . .  .  .  .  .  .  .  .  .  @  .  avrdude: Recv: . avrdude: Recv: . avrdude: Send: E  .  .  .  .  .  avrdude: Recv: . avrdude: Recv: . avrdude: Send: P  avrdude: Recv: . avrdude: Recv: . avrdude: AVR device initialized and ready to accept instructionsReading | | 0% 0.00savrdude:Send: V  0  .  .  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . avrdude: Send: V  0  .  .  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . Reading | ################# | 33% 0.13savrdude:Send: V  0  .  .  .  avrdude: Recv: . avrdude: Recv: . avrdude: Recv: . Reading | ################################################## | 100% 0.20savrdude: Device signature = 0x000000avrdude: Yikes! Invalid device signature.Double check connections and try again, or use -F to overridethis check.avrdude: Send: Q  avrdude: Recv: . avrdude: Recv: . 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.

author: TerminalJack505
author_rank: Super Contributor
timestamp: July 23, 2012, 08:26:29 am
content: 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.

author: TerminalJack505
author_rank: Super Contributor
timestamp: July 23, 2012, 09:15:30 am
content: 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: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:QuoteWhich 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?

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: July 23, 2012, 09:51:53 am
content: 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.

author: TerminalJack505
author_rank: Super Contributor
timestamp: July 23, 2012, 12:00:47 pm
content: 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.

author: madworm
author_rank: Frequent Contributor
timestamp: July 23, 2012, 02:58:43 pm
content: If you don't value your time, then by all means don't spend the huge amount of 20$ on a programmer that works.

author: MickM
author_rank: Regular Contributor
timestamp: July 23, 2012, 09:33:28 pm
content: USBTiny complete kit:https://www.adafruit.com/products/46USBTiny preprogrammed chip only:https://www.adafruit.com/products/54You can then build your own.I bought the kit, works fine for mega328Mick M

author: bsiswoyo
author_rank: Newbie
timestamp: July 24, 2012, 01:54:18 am
content: Quote from: Randall W. Lott on July 19, 2012, 08:08:08 pmdear,If you want to create your own ATmega168/328 Arduino with the Arduino IDE of ver 1.0.1 , would fail to upload program using serial.Due on the arduino of 1.0.1 version setup the configuration upload protocol to "Arduino. This configuration on folder hardware/boards.txt.You have to turn it into a STK500, because it uses a USB-to-TTL-serial dongle.More details visit my blog:http://bsiswoyo.lecture.ub.ac.id/2012/07/arduino-1-0-1-serial-upload-using-with-handmade-board-of-atmega328/Best RegardBambang Siswoyo

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: July 27, 2012, 08:21:31 pm
content: What would you guys suggest for a programmer? Cheaper is better as long as it's consistent.The USBtinyISP looks good. Is there a pre-built option? I can't solder at my apartment. I could always take a trip home to work on the soldering, though.

author: PedroDiogo
author_rank: Regular Contributor
timestamp: July 27, 2012, 08:35:26 pm
content: Also could be relevant, but I believe for this to work the ATMega on your Arduino can't be flashed with the optiloader bootloader, it must have the previous (slower) one.I had to flash mine with a bootloader from adafruit and now works perfectly.

author: madworm
author_rank: Frequent Contributor
timestamp: July 27, 2012, 08:38:54 pm
content: I've got an usbtiny as well as an avrispmkii-clone.Assembling the usbtiny was trivial, but it won't work with the newer xmega chips (3.3V) and is limited to writing 64k of flash.I got the avrispmkii clone off ebay, fully assembled, works with avrdude on linux + winblows and avrstudio. It us LUFA powered and its firmware can be updated easily. It is also much faster than the usbtiny.http://www.ebay.com/itm/USB-AVRISP-mkII-mk2-clone-ATMEL-AVR-ISP-PDI-TPI-Xmega-/160690475020?_trksid=p5197.m1992&_trkparms=aid%3D111000%26algo%3DREC.CURRENT%26ao%3D1%26asc%3D14%26meid%3D910407045742169129%26pid%3D100015%26prg%3D1006%26rk%3D1%26

author: bsiswoyo
author_rank: Newbie
timestamp: July 28, 2012, 12:14:54 am
content: Quote from: Randall W. Lott on July 27, 2012, 08:21:31 pmTo program arduino boot loader into blank ATmega328, i used USBasp programmer. And set to "Nano w/ ATMega 328".Best RegardBambang Siswoyo

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: July 28, 2012, 08:57:08 am
content: I am strictly using an SMD (QFP) ATmega168. I'm sure they'll all work for it.I think I'll pick up the AVRISP mkII.

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: August 02, 2012, 04:40:01 pm
content: I bought an AVRISP mkii programmer.I went into Atmel Studio 6.0, and selected Tools>Device Programming.The Tool, Device, and Interfaces were selected.When I click "Read" under Device signature, I get:Severity: INFOComponentId: 20100StatusCode: 0Unable to enter programming mode. Verify device selection, interface settings, target power and connections to the target device.The programmer flashes red and it says it's unable to enter programming mode.I have external power applied to my device and I'm almost certain that there are no connection issues.

author: madworm
author_rank: Frequent Contributor
timestamp: August 02, 2012, 04:49:38 pm
content: Did you get the atmel one or a clone?Anyhow, you must have the 'Jungo' driver installed. That can be a bit tricky.

author: TerminalJack505
author_rank: Super Contributor
timestamp: August 02, 2012, 04:57:46 pm
content: Your programmer's clock may be set too fast for the chip. Until you change the chip's fuses the programmer's "ISP clock frequency" can't exceed 250 kHz.This video shows you how to change it...

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: August 02, 2012, 05:28:05 pm
content: My clock frequency is set to 125kHz (less than 1/4 of 8MHz) and I have an official programmer (in the clear blue case).Also, the Jungo driver was apparently installed with Atmel Studio as it asked if I would like to allow it.The red LED is blinking whenever I click read. I followed their design guidelines.I thought it'd be a cakewalk, but of course Murphy likes me.

author: TerminalJack505
author_rank: Super Contributor
timestamp: August 02, 2012, 05:50:56 pm
content: There are a couple of ways to attack the problem that I can think of.First, you might simplify the hardware side of things. You might pop a MCU in a breadboard and provide it with the appropriate voltage and bypass caps and connect the programmer to that. This will factor-out your hardware and tell you (hopefully) whether the problem is on the hardware or programmer side of things.If you suspect Atmel's software is the issue then you can completely factor it out by using avrdude. avrdude may also give you some more meaningful error messages. (Use the -v option.)

author: madworm
author_rank: Frequent Contributor
timestamp: August 02, 2012, 05:59:39 pm
content: Using avrdude is of course an option, but on winblows this requires to remove the jungo driver and install a libusb driver. After that you can't use avrstudio anymore until you switch back to jungo.It's a shame atmel don't offer a cross-platform ide for their 8-bit micros... dick-heads. That would be much nicer than having to run the ms-bloatware studio in a virtual machine. But now we have many colorful buttons to click on...

author: madworm
author_rank: Frequent Contributor
timestamp: August 02, 2012, 06:03:36 pm
content: If there is still a device manager in winblows these days, this is what it should look like with the thing plugged in:

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: August 03, 2012, 03:13:46 am
content: Quote from: madworm on August 02, 2012, 06:03:36 pmThat is exactly what it shows. I like avrdude, but it seems like avr studio could be nice.Since this is a SMD part on a highly populated design with multiple devices on buses, I'll solder a fresh ATmega168 on one of my blank PCBs, leaving only a header. The other SPI devices could be causing problems. That would suck, because this board is about $300 worth of parts.I have an Ethernet controller, Wi-Fi module, LCD, and UART module. That would be a real pain to work with. I followed the correct guidelines by using pull-up resistors on the said lines.

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: August 03, 2012, 04:02:45 am
content: Oh, and I consistently get a Device signature reading as 0x535353. I have no idea what that means. There are no good resources about this that I can find.

author: Randall W. Lott
author_rank: Regular Contributor
timestamp: August 03, 2012, 05:32:31 am
content: I found a short that was very difficult to see by eye, since there is .65mm pin pitch. I can't believe it!Thank you all so much for all the help. You showed me just how great this forum is.