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.

Support Forum » Unable To Use Nerdkits USB Cable and ATmega32 or ATmega32A

October 02, 2010
by JimSmith4321
JimSmith4321's Avatar

I'm unable to get the NK USB programmer to work with ATmega32/ATmega32A. The foodloader compile goes fine:

bootloader32 $ make -f Makefile.fl
avr-gcc -DBOOTLOADER_DDR=DDRB -DBOOTLOADER_PORT=PORTB -DBOOTLOADER_PIN=PINB -DBOOTLOADER_PINNUM=PINB0 -DBOOTLOADER_JUMPER=1 -DSEND_BOOT_MESSAGE=1 -g -Os -finline-limit=800 -mmcu=atmega32 -DF_CPU=14745600 -std=gnu99 -Wall -W -Wchar-subscripts -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wstrict-prototypes -Wshadow -Wbad-function-cast -Winline -Wpointer-arith -Wsign-compare -Wunreachable-code -Wdisabled-optimization -Werror -Wcast-align -Wwrite-strings -Wnested-externs -Wundef -Wa,-adhlns=foodloader.lst -DDEBUG -DBOOT_SECTION_START=0x7c00 -Werror   -c -o foodloader.o foodloader.c
avr-gcc -mmcu=atmega32 -Wl,--section-start=.text=0x7c00 -L/usr/local/avr/avr/lib  foodloader.o   -o foodloader
avr-objcopy -O ihex -R .eeprom foodloader foodloader.hex
avr-objdump -h -S foodloader > foodloader.lss
make -C launcher
gcc -Wall -Wstrict-prototypes -std=gnu99 -fno-inline -O2 -Werror    launch-bootloader.c   -o launch-bootloader
===============================
compiled for: atmega32
-n bootloader size is: 
1010
===============================
bootloader32 $

I then program that foodloader.hex into the ATmega32 or ATmega32A using an STK500 with essentially the same settings as for a 328p. But when I try to use the NK USB to load a program, avrdude goes into an infinite loop:

   avrdude -c avr109 -p m32 -b 115200 -P /dev/cu.PL2303-0000201A -U flash:w:PressureSensorWithTWI.hex:a

NK USB cable is connected as follows: red: unconnected, black: ground, yellow: MCU pin 14 ((RXD) PD0), turquoise: MCU pin 15 ((TXD) PD1) I have tried setting MCU pins 20 ((ICP1) PD6) and 16 ((INT0) PD2) to ground - same result.

The ATmega31/ATmega32A breadboard is configured as: power supply = 5.0 v at VCC, AVCC, AREF, and RESET (tried RESET connected and unconnected - same result), 0.1uF cap between VCC and GND, 14.7465 crystal between XTAL1 and XTAL2, XTAL1 and XTAL2 connected to GND via 18pF caps.

Any suggestions?

October 03, 2010
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hi Jim,

While I don't have the ATmega32 or ATmega32A chips to look at here, I would suggest that you take a close look at the microcontroller's fuse settings. There are several settings that control whether a bootloader is used at all upon chip startup, and what memory location that bootloader is held in.

You might also try interacting with the bootloader via a serial terminal program to see if that code is running at all.

Mike

October 24, 2010
by JimSmith4321
JimSmith4321's Avatar

Can you please comment on mcu 328P pin 14 (labeled PB0, PCINT0/CLKO/ICP1 in the 328P datasheet) and mcu 32A pins 20 (PD6, ICP1) and 16 (PD2, INT0).

In the NK LCD project pin 14 is set to ground to set the mcu to programming mode. Which 32A pin should serve this function?

October 24, 2010
by Ralphxyz
Ralphxyz's Avatar

"But when I try to use the NK USB to load a program, avrdude goes into an infinite loop:

    avrdude -c avr109 -p m32 -b 115200 -P /dev/cu.PL2303-0000201A -U flash:w:PressureSensorWithTWI.hex:a"

On a 168 and 328 that hang up is usually fixed by unplugging and replugging in the USB cable. A alternate fix is a reboot.

Just out of curiosity if you have a STK500 couldn't you load a program using ISP without having a bootloader?

That might be a good way to check your fuse settings also.

Ralph

October 24, 2010
by Rick_S
Rick_S's Avatar

Unless you changed the code in the bootloader, PB0 is located on pin 1 of the Atmega32a. That would be the pin that would have to be grounded to place the bootloader into programming mode.

Rick

October 24, 2010
by JimSmith4321
JimSmith4321's Avatar

Rick_S --- Thanks, I do understand which pin PB0 is - I want to know which pin serves the same function (setting the mcu prepared for in-system-programming) in the ATmega32A as 14 does with the 328P. Ralphxyz --- yea I've found that same fix. I want to use the NK programmer for in-system-programming. That is to use the STK500 I have to remove the mcu from its application circuit and place it in the STK500. With the NK USB isp I won't have to that. Thanks anyway guys.

October 24, 2010
by Rick_S
Rick_S's Avatar

Pin 1 on the Atmega32 is the equivlant of pin 14 on the 168/328. Pin 1 of the Atmega32 would be the pin to ground to put the 32 into programming mode if the bootloader was compiled with it's default settings.

Rick

October 24, 2010
by Rick_S
Rick_S's Avatar

Also, you do realize to install the bootloader, you will have to use the ISP programming from your STK500. You will also have to set the fuses to configure the bootloader space and lock it so it won't get overwritten. You should be able to figure out the fuse settings by looking at the fuse settings for the 168 or 328 and determining what the equivalent in the 32 would be.

Rick

Post a Reply

Please log in to post a reply.

Did you know that NerdKits has been featured in the MIT Undergraduate Research Journal? Learn more...