Programming standalone Atmega 328p AU - uploading using programmer

Hi

Im trying to program (not necesarilly bootload) an Arduino sketch into an Atmega 328p AU (smd) that is on a custom PCB board. I've access to all the SPI pins and the reset pin, and I've these guys connected to the ICSP header on the Arduino UNO.

However, while programming the board via File -> upload using programmer I'm getting an avrdude error:

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding

I've edited avrconf to accomodate the SMD signature to signature = 0x1e 0x95 0x0F; and Im still getting this error.

The microcontroller is taken out of the Arduino.

How do I program the SMD atmega? Or, how do I bootload that Atmega, so that I can upload sketches later?

The chip I put on the board is brand new 328pAU, although Im afraid if it is not using its internal oscillator and that might be causing the problems. The chip is not in reset.

Cheers

To program another Atmel chip with the Uno over ISP, you must upload ArduinoAsISP sketch to the Uno, connect a 10uf (or thereabouts) capacitor between reset and ground on the Uno (this clobbers auto-reset, which will otherwise prevent ArduinoAsISP from working), and you must make the connections correctly. You do not remove the microcontroller from the Uno board - you need that microcontroller there, running the ArduinoAsISP sketch.

Connecting the ICSP header on the Uno board to the ISP pins on the other board will not work, because that would connect the reset on the target board to reset on the Uno. What good is that!? See the comments in the ArduinoAsISP sketch for the correct pin on the Uno to connect to Reset on the target board.

I've followed those instructions as well; no luck though. Im getting the 'not in sync' error.

Im afraid that I need to provide an external clock to the circuit, and I was wondering if I could hack into the dip socket on the UNO to get the clock signal from there?

Kurak:
I've followed those instructions as well; no luck though. Im getting the 'not in sync' error.

Im afraid that I need to provide an external clock to the circuit, and I was wondering if I could hack into the dip socket on the UNO to get the clock signal from there?

Are you actually doing upload using programmer, not normal upload? With the com port of the Uno selected from port menu and ArduinoAsISP selected from programmer menu? (not ArduinoISP, which is something else)

There are ways to get a clock signal out - but you are not getting far enough for that to be the cause of the errors. You'd get a different error if that was the problem - the error you're seeing indicates that it's failing to communicate with the ISP programmer.

If the problem is that it's set to use an external clock but one isn't present, it will report that the chip has the wrong signature, and if you use verbose uploads, it will show that the signature is reported as 000000 (this error can also indicate wiring problems between programmer and target)

I've uploaded (successfully) the ArduinoISP sketch to the UNO board.

Then I've connected my PCB with 328pAU to ICSP header (and reset to pin 10), 10uF cap between reset and ground.

Then Im using Arduino as ISP from the programmer menu, and upload using programmer to upload a test sketch to my custom board.

Still getting and out of sync message.

After using and AVR MK 2 I've gotten a 0x0000 device signature, tried two different processors. The only things connected now are power and ICSP to the uC, no caps, no resistors. uCs are factory new.

Kurak:
Then I've connected my PCB with 328pAU to ICSP header (and reset to pin 10), 10uF cap between reset and ground.

Try connecting to the SPI pins (11, 12, 13) on the Uno and not to the SPI header on the Uno.

Don't forget to select Arduino As ISP.

You probably need to provide external clock signal to the chip or connect a crystal circuit while setting the fuses in order to use the internal clock. If you don't want to or can't connect a crystal then explore using a programmer which provides a clock signal. Like perhaps GitHub - adafruit/ArduinoISP: A fork of the ArduinoISP that has 8mhz output clock

Okay, so the clock was the problem.

By default, the Atmega 328p AU comes with internal 8 MHz oscillator enabled, but also the clock divider by 8 is enabled, resulting in 1 Mhz real speed. Therefore, the data transmission must be slowed down. I've achieved this by using AVR dragon programmer to set the fuse bits, but it also can be probably hacked by editing the boards.txt in order to force lower upload speed.