Programming ATMEGA328P-PU on custom PCB

Hi guys so I am currently developing a custom PCB based around the ATMEGA328P-PU chip and have some questions about burning the bootloader and programming the chip. Is it possible to burn the bootloader to a blank chip with the usb or do I need to use the ICSP Header.

The reason I want a usb port on my pcb is for datalogging to excel in real time to help tune my program.

Also any schematics and part numbers for the usb would be great!

You need the pins that are on the ICSP header. Have a look at this tutorial
The mega 328 has no generic usb so you will need an ftdi chip or similar. An other optin is using an avr with built in usb. A third option is using vusb

I would like to avoid using an addition arduino to program my pcb as it will be in a truck so i would like to just run a usb cable from my pcb to my laptop in order to burn the bootloader, burn the program, and datalog.

Would something like this work for what i am trying to do?

Could i just copy the schematic and implement it directly into my pcb?

Is it possible to burn the bootloader to a blank chip with the usb or do I need to use the ICSP Header.

You need an ICSP connection (not necessarily a header, but that makes it easier).

You can always use a FTDI cable and avoid having to solder a USB interface in.

The Sparkfun product would achieve a similar result. I'm not sure what you really gain by soldering the USB interface onto the board. That means if you make 5 boards you need 5 USB interfaces, but if you use the FTDI cable you only need one cable (and just solder on the FTDI header).

Fairly extensive descriptions and schematics in my link above.

How many i/o do you need? analog? digital?
I have been playing with the thought of adapting the Trinket firmware to a ATTINY1634.

I am currently only using 2 analog and almost all of the digital. I have attached my schematic in which i implemented the ftdi header and icsp header according to gammon's schematic. Please verify that this will work.

Just to clarify, you cannot burn the bootloader to a blank chip through ftdi correct?

Steps to program chip:
1: Burn bootloader via arduino uno through icsp header
2: Burn program via ftdi
3: Datalog thruough ftdi just like it was from the usb on an orginal uno

Also is this the correct ftdi cable?

Mitch,

Although the *RESET line on the FTDI connection uses a 0.1uF cap, I've always directly connected my ICSP to *RESET. So I don't think you need C7 in your drawing, and it may even keep the programmer from working. Nick - If I'm wrong, please set me straight.

Also (and this is just my 2 cents), you can get you FTDI cable from Digi-key, but if you go Adafruit (FTDI Cable or FTDI Friend), you can get a lot of help along with the cable. Jus saying.

And yes, you can't really use FTDI to load anything on a blank (without bootloader) 328. And you can't really load a bootloader with FTDI, because it is a bootloade,r so the FTDI bootloader would have to overwrite itself.

Thanks so much for clarifying that now I can hopefully finish my first ever pcb layout!

The capacitor is there for a good reason:* To turn the "low" on RTS into a pulse:

  • However see reply below.

From my page ( Gammon Forum : Electronics : Microprocessors : How to make an Arduino-compatible minimal board ):

The capacitor is there to turn the RTS signal into a pulse, so that when the computer brings RTS low, it briefly pulls reset low, and then the pull-up resistor charges the capacitor again, bringing reset high again.


I've always directly connected my ICSP to *RESET.

Yes, but this is the FTDI interface, not the ICSP one.

Oh wait, he has two capacitors! I didn't spot the second one on the ICSP reset.

The one on the ICSP line is wrong, you are correct.

@mitchedwards: Omit C7.

With C7 there, /RESET would not stay low and you would be unable to program the chip, as ICSP programming holds /RESET low during the entire programming sequence.

There is also a diode advised for reset, see here:

This is because during RTS pulsing it can overshoot temporarily, reaching over 5V, and possibly putting the chip into high-voltage programming mode. The IN4148 diode in parallel with R1 on my schematic prevents /RESET exceeding Vcc (by much, anyway).


The Uno Rev3 board has such a diode.