ATmega328 with USBasp Programmer Troubleshooting

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am trying to connect to an ATmega328 on a breadboard using a USBasp programmer. I have successfully connected to an Arduino uno using this programmer and avrdude, however the methods are not translating to my breadboard set up. This is the error resulting from the following command:

 

avrdude -p m328 -P /dev/ttyS1 -c usbasp

 

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

 

I understand this is most commonly the result of incorrect wiring—I have checked and double checked the wiring, which seems to be in order.
On the USBasp header, male pumpers are attached as follows (see the photo for breadboard wiring.)

 

Orange=MOSI
Grey=MISO
Green=SCK
Blue=RST
Red=VCC
Black=GND

 

The voltage across the gnd/VCC cap is a steady 5.06V

Additionally, i have an ATmega168A and ATtiny45 which have brought me to the same error. Notably, it was a bit challenging to snap a couple of these chips into the board; the only thing i can surmise is that there are one or more faulty connections within the breadboard to my programmer pins.

 

Thanks for any help!

 

 

***UPDATE: I am now communicating with the MCU. I soldered a jumper to JP3 of my USBasp, which slows the programmer clock speed. From USBasp documentation:

"J3 SCK option
   If the target clock is lower than 1,5 MHz, you have to set this jumper.
   Then SCK is scaled down from 375 kHz to about 8 kHz."

Attachment(s): 

This topic has a solution.
Last Edited: Tue. Jul 21, 2020 - 04:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why have you not connected both sets of power pins. It is not optional.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't use color code in jumpers. They will mislead your connections. just do as miso of usbasp to miso of avr, so as the mosi,sck,rst,sck. apply 5v to both Vcc and AVcc and use 22pf with your crystal and you should be good to go

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I think it is an excellent idea to quote jumper colours in your custom wiring.

It means that readers (and you) can check your wiring in the photos.

 

Yes,  I would provide power to AVCC, GND on 20, 22 as recommended by datasheet.

 

You appear to have wired correctly.   Breadboards can have loose connections.  Jumper wires can be bad.

But most likely that you have previously programmed clock fuses wrong.

 

Apply an external clock to XTAL1 pin.   Restore clock fuses to "Internal 8MHz RC"

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

How many threads have we had here lately on "my bare AVR on a breadboard does not work"!?? 

If you insist in using a BB, then use a BB friendly AVR's known as Arduino Nano, or Pro-Micro, you don't have to use the Arduino IDE if you don't want to, but the h/w is sound and will work every time, why mess with dodgy connections and all really!

 

Jim

BB's suck!

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@OP

 

Have a look at this...

 

https://www.avrfreaks.net/forum/...

 

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had read from another reference (Make: AVR Programming by Elliot Williams) that hooking up the ADC power pins is not essential in order to get up and running (though it would be good practice to hook up both ground lines in a PCB design, for example). As per the datasheet, I tried adding the ADC power pins, but with no success.

Last Edited: Mon. Jul 20, 2020 - 08:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ChooChooTrain wrote:
that hooking up the ADC power pins is not essential in order to get up and running

The data sheet disagrees, as more then just the ADC is powered by that pin, including the BOD circuit, which if enabled would prevent the chip from running as it would sense a low voltage.

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are these new, bare chips or have your recycled them from an existing Arduino board ? If you have, they will be configured to expect a 16MHz crystal. Do you have one, and a couple of 22pF caps, to hand ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Some M328's come with an Arduino bootloader and fused for a xtal, depending on your source for these.

Use an Arduino Uno as a clock source and feed it into pin xtal1/gnd and see if it comes alive.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your reply. Your comment about the clock fuses is my last option--I'll have to read up on how to do this correctly.

 

Can you confirm that this solution is still relevant given that the chips were received un-programmed from the distributor (evidenced by the spread prongs), and that I have never programmed the clock fuses previously?

 

Thanks again!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ChooChooTrain wrote:
Can you confirm that this solution is still relevant given that the chips were received un-programmed from the distributor

Which distributor?  Mouser/Digikey will deliver them with factory default, but I think you can also order them with Arduino bootloader, fused for xtal as well.

Many Ebay sources have them setup for Arduino.

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I got them fresh from Digikey, unprogrammed (though Digikey offers customized orders preprogramming the MCUs). There are other distributors that offer these pre-programmer with Arduino bootloader as well, but I don't really need this, as I'd prefer to get up and running with my external USBasp.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I see no pull-up resistor on the RESET line. Maybe the thing's permanently in reset. Try a 10K resistor from RESET to +5V (and a 100nF cap from RESET to ground).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nada :-/

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

***UPDATE: I am now communicating with the MCU. I soldered a jumper to JP3 of my USBasp, which slows the programmer clock speed. From USBasp documentation:

"J3 SCK option
   If the target clock is lower than 1,5 MHz, you have to set this jumper.
   Then SCK is scaled down from 375 kHz to about 8 kHz."

I've read here and there that the default clock speed of most AVR MCU's (including ATmega328) is 1 MHz. If that is the case, then the JP3 solution makes sense since 1MHz is the lower limit of the target speed cited above.