How to add programming over USB to AVR mcu?

Hi!
I wish to make my own microcontroller board (for the challenge), I've got everything down, but how to program it over USB. Arduino UNO uses the Atmega8, I haven't a clue on how to do this?
Can anyone help, and thanks in advance.

What exactly do you have "down"? and what don't you have down?

1 Like

I've designed and tested the rest of the board, I am only missing the programming over USB.

So... an FTDI adapter like one of these?

You can't programming your board over USB without external hardware and software - (USB-UART transceiver) and bootloader.
I don't know is a bootloader for atmega8 existed.

I generally doubt very much that you need over USB programming for your board. Since you will still need an external adapter, in my opinion it's easier to upload sketches via ISP. In addition, the bootloader takes up space in the chip's memory, which the atmega8 does not have very much anyway.

You need to add USB-UART device for that. Atmega8u (u is for USB support) programmed in the right way can do this. Alternatively you can use chips CH340 or CP2102 - USB-UART is their only function, no programming required. You need to connect that chip's D+, D-, 5V, GND to USB connector - and TX, RX to Arduino's hardware RX, TX correspondingly. You also need connect DTR of that chip to a 1 uF capacitor, and the other side of capacitor - to atmega's RESET pin (and add 10k pullup resistor on reset) - that is necessary to perform reset and start atmega's bootloader when upload process is started. Do that - and it will work :slight_smile:

You posted in the wrong sub forum. This one is for things like interfacing python scripts on a PC...

Thank you!
This is exactly what I was looking for!


This my schematic, anything incorrectly done?

errmm... yep, your USB connector makes no sense whatsoever!
DP1 connected to SBU1 - why?
DN2 not connected at all - why?
CC2 connected to D-, why??? (D- aka DNx must be connected to each other and nothing else, just like D+, DPx)
CC1, CC2 don't have 5.1k resistors to ground -> it won't work with USB-C cables
CP2102 has no decoupling capacitors and pullup resistors - check its datasheet for reference schematics, "Figure 5. Typical Connection Diagram" - don't use all optional components except for pullup on RESET pin.

Connection from CP2102 to atmega seems to be fine (hard to trace those long wires - I always use labels instead of wires for all digital signals with clear roles)

Damn!
Looks like I accidentally moved the whole connector, causing the wierd connections.
I figured my schematics are a nest of unreadability. So I fixed it.
Added the missing components, hope I didn't badly mess something up. Thank you for the help!

I see )) Yes, now USB is good. CP2102 is good (or if there is anything wrong, I'm missing it :slight_smile: ), connections are clear - but I've noticed that crystal capacitors C1 and C2 are different (22 and 0.22 pF) - that most likely is wrong unless you have some very special model, most likely both should be equal at 22 pF (but you need to check vs crystal specs, I for instance normally use crystals which need 12 pF)

1 Like

Also I don't see larger capacitors around voltage regulator. Normally you need 1 uF ... 4.7 uF caps on both input and output of the regulator (need to check its datasheet for recommended values - and don't add more than specified, counter-intuitively, more isn't better there)

Hi!
I've read the documentation and added the specified caps. My question: is it really necesarry to have all these bypass capacitors on every individual component that specifies them?

Yes, those caps are necessary - and more than that, on the PCB they must be placed really close to supply pin of the corresponding chip (preferably within 1-2 mm distance). Their role is to provide stable current when chip performs intense operations - for each operation, for some nanoseconds chip needs a lot of current, and if this current will be supplied via a long wire - that would affect stability.
For that to work, PCB design must have a ground plane - mostly solid polygon connected to supply's ground (it's ok to cut through it here and there for routing traces, but it's not ok to make a large slots in it, or worse, cutting it completely with a long bottom trace). All capacitors should have ground connection with a via next to their ground pads.

Also it's critical for such capacitors to be ceramic ones (MLCC) - electrolytic capacitors can't operate in this role due to high internal resistance.

In many simple cases it will work without them - but the higher is operation frequency, the more sensitive becomes analog part, the higher are external EM fields - the more important that becomes. For something like RPi CPU, poor routing or lack of capacitors would lead to complete failure. For something like ESP32 chip (not module - critical stuff is taken care of in modules - but raw chip), failure to properly address that would lead to very poor stability with random freezes and reboots.

For atmega328 that's not critical - but it's best to learn the right way from the start :slight_smile:

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