2
\$\begingroup\$

My objective is to program a single ATmega328P sitting on a breadboard. Due to my location and cash at hand I cannot acquire a AVR ICSP programmer so instead (through research) I found I can use a arduino as a AVR programmer and decided to use it.

The ArduinoISP sketch was uploaded to my Arduino Uno R3 successfully and the appropriate pins were hooked up to my breadboard.

I wrote a simple C program in Atmel Studio and compiled it to a intel hex file then proceeded to use avrdude to upload the file to the μCU. Avrdude reported a successful flash (verification successful as well) but the μCU doesn't seem to be responding.

The simple C program as below:

//Define CPU speed to 1 MHz (8 MHz internal with CKDIV8)
#define F_CPU 1000000

#include <avr/io.h>
#include <util/delay.h>

int main(void){
    DDRC = 0xFF; //Set all of port C to outputs

    while(1){
        PORTC = PORTC ^ 0xFF; //Toggle all of port C
        _delay_ms(500); //Delay 500ms
    }

    return 0;
}

Command used to send the flash to the Atmega328P:

$ avrdude -c arduino -p m328p -P COM9 -U flash:w:"compiled_file.hex":i

A single LED (with 220 ohm resistor) was hooked from ground to pin PC5. If my logic is correct this light should toggle on/off every 500ms but the light remains off. The LED has been tested and connection polarity confirmed (positive to pin, negative to ground).

As a side note, I also found that when I told avrdude to read the fuse settings on the μCU, they all registered to be 0x00, which is quite strange.

Any help would be much appreciated.

Update:

Through some experimentation I found that the command listed above was somehow telling avrdude to program the ATmega328P on the arduino uno itself rather than the ATmega328P on the breadboard. I've successfully reflashed the ArduinoISP to the Arduino so I'm back to step one. Does anyone know how to get avrdude to write to the ATmega328P on the breadboard?

\$\endgroup\$
  • \$\begingroup\$ Have you ever used that particular ATmega chip before? Just wondering if maybe it has odd fuse settings rather than the default, I guess it might be worth trying to set them either way to see if it makes a difference. \$\endgroup\$ – PeterJ Mar 30 '14 at 8:52
  • \$\begingroup\$ @PeterJ Brand-new mega328P. Tried setting fuses, it "worked" (I think?) but the verification stage told me that the fuses were still 0x00. I'm assuming for some odd reason fuse detection is not working. \$\endgroup\$ – initramfs Mar 30 '14 at 9:07
  • \$\begingroup\$ Having the schematic (or even the wiring diagram) of your connections would be helpful. Or did you implement exactly this one? \$\endgroup\$ – Dmitry Grigoryev Mar 7 '16 at 14:47
1
\$\begingroup\$

Reading through the question, it sounds like you forgot one of the required components.

Running AVRDUDE will cause the host MCU to reset. In order to prevent this, you need to put a capacitor on the host's nRESET line to keep the voltage above a certain threshold. Add the capacitor as described in the ArduinoISP article and try again.

\$\endgroup\$
  • \$\begingroup\$ This step was already performed. I also tried removing this capacitor to test the effects, which resulted in no difference. The problem is avrdude is writing to the arduino's ATmega328P (I can remove my target AVR and the avrdude command still executes without issue). \$\endgroup\$ – initramfs Mar 30 '14 at 23:01
  • \$\begingroup\$ If nRESET was properly suppressed then there'd be no way to write to the onboard MCU since its bootloader would never run. Try a larger capacitor. \$\endgroup\$ – Ignacio Vazquez-Abrams Mar 30 '14 at 23:03
  • \$\begingroup\$ The capacitor I used was 100 μF (didn't have any 10 μF caps around at the time), unless that is still "too small"... I don't think the capacitor is the issue. \$\endgroup\$ – initramfs Mar 30 '14 at 23:07
-1
\$\begingroup\$

I've encountered exactly the same problem last week.

Avrdude report m328p(uno) signature, while I am programming ATmega8A.

The ArduinoISP programmer should be:

avrdude -c stk500v1 -b 19200 
\$\endgroup\$
  • 1
    \$\begingroup\$ Can you elaborate your answer a bit ? I tried to edit but I can't even understand what you're trying to say \$\endgroup\$ – MaximGi Mar 7 '16 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.