[SOLVED] Program Atmega328P-PU mounted on an Arduino UNO with an USB ASP; "target doesn't answer" error

Hi, everyone.

I have some Atmega328P-PU with preinstalled Arduino bootloader.
If I mount them on an Arduino UNO I can program them from Arduino IDE via the UNO USB. So they work and the bootloader is actually installed.

For a project, I want to use them with a lower clock, so using the internal 1MHz. So, I need to se the fuse registers.
Since I don't have a breadboard setup, I hoped to do this by connecting the USBASP programmer directly to the Arduino via the ISP pins.
Awfully, the IDE gives me this error:
avrdude: error: program enable: target doesn't answer. 1

What I tested so far

I have an home made "programming board", where I can connect the USBASP ISP signals to 3 type of AVR (8 pins, 20 pins, 28 pins). No crystals; it will work on standard processors, working with internal clock.
Using USBASP + avrdude I was able to communicate (read/write the fuse) to a ATTiny85 (8 pins) and an Atmega8l (24 pins). So, USBASP works, and the programming board is wired correctly.
I couldn't communicate with the Atmega328P. I bought them several years ago, and didn't remember if they had a bootloader.

I connected one to the Arduino UNO and, as sid, I was able to program it with the Blink example.
I confirmet that they have the bootloader preinstalled. That explains why I couldn't communicate with them on my programming board (no external clock provided).

I then connected the USBASP to the Arduino UNO. I connected the 6 used pins with 6 "floating" cables (not a premade cable). I've checked three times that everything was connected as expected. When connectin USBASP to the PC USB, the UNO turns on and the Blink program loaded to the micro runs. At least ground and VCC are connected corretly :slight_smile: THe other signals are connected 1:1 (MISO to MISO, MOSI to MOSI, ...).

I've installed the breadboard sketch (copied the folder in Arduino/hardware). I then selected "ATmega328 on a breadboard (8 MHz internal clock)" as target board and USBAsp as programmer. Then Sketch->Upload Using Programmer.
And got the mentioned error
Awfully, the IDE gives me this error:
avrdude: error: program enable: target doesn't answer. 1

I get the same error launching avrdude from cmd to read the fuse bits. I expect it to work once the processor is mounted on the UNO (external oscillator available).

On the USBASP I connected the jumper to hawe it work at 5V. Also tried connecting the "slow clock" jumper, without success.

Am I missing something?
Any hints to be able to program the Atmega328 (with bootloader) with USBASP? If I can avoid setting up a breadboard and use the UNO I'll be grateful :slight_smile:

Only if you want to use the internal clock. You can use the clock prescaler to divide an external clock to give you 1MHz or even less.

If the 328 already has a bootloader, then you need to connect a 16Mhz xtal in order to program it via ICSP

I prefer to use the internal clock. Since the "slow" internal clock is enough for my trivial application (as you already know : ), I prefer to avoid extra external components.

The 328 is on the UNO board, so the 16MHz xtal is there, right?
Thought it was enough to have it programmed/controlled via ISP by the USBASP.

Yes but your description was a little confusing since you said home made programmer board no crystals.

If you plug your 328 into an Uno you should be able to program it with a USBASP programmer via the ISP pins.
What bootloader are you trying to program into the 328?

Sorry for the confusion. I added the "story" regarding my programming board to state that the USBASP is working.
Now the 328 is plugged in the UNO.
I'm not programming any bootloader. I'm trying to program the Blink sketch with the USBASP instead of using the UNO USB/programmer.

Actually, this is just the "first test", and I'm not even sure I need it. My tought is that if the programming works, the USBASP can communicate with the 328, so I can then use avrdude from command line to set the fuse bits.

So, what I actually need is:

  • set the fuse so the internal clock is used
  • plug the 328 in the programming board
  • program and test my programs directly from the programming board
    I already do the third step with an ATTiny85, programed with USBASP from Arduino IDE.
    The problem here is that I'm not able to communicate with the device (i.e. program it), so I'm stuck at the first step.

It should work. All I can say is check your connections and make sure your USB cable is good.
Do you have Uno selected?
Do you have USBasp selected?
Are you selecting "Upload using Programmer" ?

I'm only connecting the USBASP USB, not the UNO USB cable. Do I need to connect it, too? Won't the two 5V power "fight" each other?
I've also re-checked the connections. Looks good.
Just to be clear, I'm using the 328 ICSP connector on the UNO, not the "USB interface" ICSP.
I've reproduced the pinout of the Arduino 6 pin ISP connector on my programming board, so I just have to move all the cables as-is from that to the UNO.

No, I selected "ATmega328 on a breadboard (8 MHz internal clock)". But I got the same behavior selecting "Arduino UNO".

Yep

Yep.
I noticed that, when I press "Upload using programmer", the UNO LED (blinking from the Blink sketch currently loaded on the 328, programmed with UNO USB) starts blinking faster. So something is happening.
I don't need to load anything fancy on the 328 before this operation, right? Like something that doesn't drive the CSI pins (at the moment the blik program is driving pin 13, that is the SCK). The programmer will reset the processor, so the pins aren't driven, right?
Just to be sure, I've edited the Blink program to drive pin 7 (a random pin that won't interfere with the programmer) and programmed it via UNO interface. Still can't re-program it with USBASP.

I've read someone having issue due to the USBASP firmware version. Have to check that. Will report later.

Not if you programmer supplies 5V to the Uno board.

I don't need to load anything fancy on the 328 before this operation, right?

No nothing.

I've read someone having issue due to the USBASP firmware version.

That I don't know about and I'm out of ideas

I'm back!
Out of ideas, I opted for building an "Arduino on breadboard" and see if I get a different behavior with respect to my test on the UNO.
And I did get a different behavior!
With this configuration I was able to communicate with the Atmega328P with avrdude and USBASP. Yay!
And I was able to set it to use the internal clock at 1MHz, that was my main goal.
Also, can program via Sketch->Upload Using Programmer.
Alsoalso, can program on my programming board (once the Atmega328 is set to internal clock).

I have no idea why it didn't work on the UNO, but I solved my issue.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.