NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » Flashing foodloader onto a blank 168-PU

January 12, 2011
by n3ueaEMTP
n3ueaEMTP's Avatar

A few questions for the experts:

Question 1: I am trying to flash the bootloader to a new 168-PU that I picked up from Mouser. I'm using PN and flashing via tools --> [WinAVR]make all which has worked well for me up to now. I know that the wires are placed correctly because I can program a few 328Ps I have on hand. The only thing I did was exchange MCUs on the breadboard. Pins 7, 20, & 21 are to VCC. Pins 8 & 22 are to GND. The 14.7456 crystal is installed on pins 9 & 10. I'm using this programmer from Sparkfun. Here are the results of my programming attempt returns. Any Ideas?

    avrdude -c usbtiny -pm168 -B1 -F -U lock:w:0x2f:m

    avrdude: initialization failed, rc=-1
    avrdude: AVR device initialized and ready to accept instructions
    avrdude: Device signature = 0x000000
    avrdude: Yikes!  Invalid device signature.
    avrdude: Expected signature for ATMEGA168 is 1E 94 06

    avrdude done.  Thank you.

    make.exe: *** [fuses] Error 1

Question 2: One of my programs is about 15Kb so I want to program it directly on the 168. Will removing this line in the makefile just set the fuses so I can use my programmer linked above to program the uC?:

install:
    avrdude ${AVRDUDEFLAGS} -U flash:w:foodloader.hex:a

Thanks in advance for any help!!

Chris B

n3ueaEMTP

January 13, 2011
by Ralphxyz
Ralphxyz's Avatar

Are you using the Nerdkit breadboard? You will need a separate programer. Search the forum for ISP (Inline Serial Programmer).

You can get cloned ISP programmers off of Ebay or you can get a supported programmer from ATmel, I use the ATmel Dragon (which has it's issues).

Ralph

January 13, 2011
by n3ueaEMTP
n3ueaEMTP's Avatar

Ralph, I'm actually using this programmer from SparkFun Electronics. This is actually my third batch of MCUs from Mouser. I didn't have any problems with the other two batches, however, the other two batches I just burnt the NK bootloader on all the chips. This time, all I'd like to do is burn my program without the bootlaoder. At this point, I'd be happy to just get the bootloader onto one of the MCUs.

Thanks.

Chris B, n3ueaEMTP

January 13, 2011
by n3ueaEMTP
n3ueaEMTP's Avatar

All, after hours of google searching, I found my problem. The -B1 flag causes the ISP to program too fast for the MCU with the 1Mhz clock speed (factory default).

Changing :

avrdude -c usbtiny -pm168 -B1 -F -U lock:w:0x2f:m

To:

avrdude -c usbtiny -pm168 -F -U lock:w:0x2f:m

resolved my problem!

Now all I need to figure out is if I can do all this without the bootloader!

Thanks All!!

January 13, 2011
by Ralphxyz
Ralphxyz's Avatar

What confused me was your referencing the Makefile.

I am just now learning AVRstudio to be able to build the hex and to flash the mcu in the same IDE.

I use one mcu with the bootloader to load a program onto that mcu with the bootloader than I use the .hex to flash the new mcu, without boot loader, using my Dragon.

Using AVRstudio I should be able to build the .hex and then flash the mcu saving some steps.

Ralph

January 13, 2011
by n3ueaEMTP
n3ueaEMTP's Avatar

Wow, that sounds like a lot of work to get a program onto the MCU without the bootloader. Having no other experience, I use only the things that came with my nerdkit (software speaking). I just modify the makefile in Programmers Notepad and compile my programs from there. That is why I was confused, I have no other reference. Since I now have the AVR pocket programmer (link above) I wanted to try to get a program on without using the bootloader. Getting the program on the MCU wasn't too tough but the program didn't run because the fuses were set wrong. I modified the makefile in the bootloader folder by deleting the following lines:

install:
    avrdude ${AVRDUDEFLAGS} -U flash:w:foodloader.hex:a

I then ran make through PN and the fuses were set. All is now well!!

Post a Reply

Please log in to post a reply.

Did you know that the Timer/Counter modules on the microcontroller can be configured to output a PWM (Pulse Width Modulation) signal? Learn more...