Search code examples
microcontrolleravrdude

avrdude unable to program my ATmega328p microcontroller


I am going to be brief here. So I got my Atmega328p microcontroller from Arduino Uno(I pulled it out of the board). And then I bought my USBASP programmer chip to program my MCU. I properly installed its x64 drivers. Then I made my program to turn an LED on. It got compiled successfully and generated the hex file nicely. BUT! when I try to program my MCU it gives an error like this:-

ERROR LOG:-

avrdude -p atmega328p -P usb -c usbasp    -U flash:w:LEDON.hex 

avrdude: error: programm enable: target doesn't answer. 1 
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

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

Then I try to program it using the -F parameter to know the problem more deeply, and I get this error:-

avrdude: error: programm enable: target doesn't answer. 1  
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 ATMEGA328P is 1E 95 0F  
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
    To disable this feature, specify the -D option. 
avrdude done.  Thank you. 

I have tried everything, but nothing is working. I am using WinAVR on Windows 10 x64 OS. I can put the code if you guys want. Also I have double checked my MOSI, MISO, SCK, RST, Vcc and GND connections. They are perfectly fine.


Solution

  • Yes, you are correct my friend. I found my own solution after 1 week of searching. The images for the 6 pins were all wrong on the internet. So, I did a little more digging and i found the correct 6-pin mapping on the arduino official site. I had lost all hope but when a gave it a shot it worked!
    https://www.arduino.cc/en/Tutorial/ArduinoISP
    This is the link where you guys wil find the proper pin mapping. Thank you for your reply πάντα ῥεῖ.