2
\$\begingroup\$

I am trying to program an ATmega128 microcontroller (bought from Robokits). I have connected the 10 pin ISP header from the USBasp programmer to the 6 pins (MOSI, MISO, SCK, RESET, VCC, GROUND) of the MCU.

But whenever I try to program the MCU the result is:

C:\Documents and Settings\intern>avrdude -p m128 -c usbasp
avrdude: warning: cannot set sck period. please check for usbasp firmware update
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.

Also I tried connecting an external 8MHz crystal to the MCU as indicated in this post, but it didn't work.

ATmega128 - Image

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Are you supplying power to the ATMega? Try also adding the -B 1 argument to the avrdude command line \$\endgroup\$ – EkriirkE Jun 17 '14 at 6:49
  • \$\begingroup\$ The VCC of the ATmega is connected to the Vcc(2nd pin) of the 10 pin ISP header \$\endgroup\$ – Bishal Jun 17 '14 at 6:54
  • \$\begingroup\$ That doesn't necessarily mean the ISP/programmer is supplying power to the uC. Atmel's own AVRISP MKII doesn't even power the target (without hacking it) and won't program. \$\endgroup\$ – EkriirkE Jun 17 '14 at 7:03
  • 1
    \$\begingroup\$ Do you have any capacitance across the power supply connections of the ATmega? You should have one 0.1 uF capacitor per Vcc pin. Also, you need to hook up all the power and ground pins. I cannot tell if you did that from the images. \$\endgroup\$ – Connor Wolf Jun 17 '14 at 10:22
  • 1
    \$\begingroup\$ OP, should all else fail, I would recommend you check out this article here. It talks about setting up Atmel Studio with the USBasp in general but does a good deal of discussing use the USBasp. shannonstrutz.com/?p=629 \$\endgroup\$ – Funkyguy Jan 9 '15 at 9:23
2
\$\begingroup\$

Pin 1 (nPEN) is supposed to be held low during power-on, so the SPI programming is possible.

nPEN has internal pull-up, so grounding this pin during power-on is a must, otherwise you cannot program it with the USBasp.

"PEN is a programming enable pin for the SPI Serial Programming mode, and is internally pulled high . By holding this pin low during a Power-on Reset, the device will enter the SPI Serial Programming mode. PEN has no function during normal operation. "

So you will need to remove the grounding on Pin 1 for normal start up behavior.

  • You will also need to use the pins PE0 as MOSI, PE1 as MISO, and SCK as SCK. This is all described in the SPI Serial Programming section on page 300 in the datasheet for ATmega128.
\$\endgroup\$
  • \$\begingroup\$ Grounding PEN is optional since the programmers can put SCK to LOW when raising RESET signal. PEN must be used when SCK is not guaranteed to LOW when resetting. I have tested to work with floating PEN (internally pulled-up) and the USBAsp and BusPirate programmers. \$\endgroup\$ – caligari Nov 12 '18 at 0:13
0
\$\begingroup\$

@Bishal

I too have exactly the same programmer and it looks to me that the MISO and the MOSI are interchanged in the ISP header pins.

However, in the zif socket they seem to be connected to the right place for a 40 pin chip. Probably swapping MOSI and MISO on the ISP pins may work for you.

\$\endgroup\$

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.