How to upload sketches to standalone ATmega328 ics on breadboard using Uno

:confused: :confused: :confused:

I have recently bought some bootloaded atmega 328 ics from Amazon , for standalone projects which I want to program using Arduino Uno as a programmer.

I have already visited many websites, all of them are teaching how we can burn a bootloader , but these ics are already bootloaded so I don't need to bootload it anymore. I have not yet been able to figure out how I can upload a sketch to the atmega328 on breadboard using Uno board as a bridge between arduino and PC.

Also, many of the tutorials ask to remove the arduino uno factory installed atmega ic, but I want to keep that arduino ic on and upload sketches along with it to the standalone atmega which is placed on the breadboard.

I don't know whether the question has already been answered, if yes, please give me link , otherwise , please help me out.

Also please avoid suggesting any ftdi type devices until there is no way left.

Thank you so much for your precious time :slight_smile: :slight_smile:

bitrux:
Also please avoid suggesting any ftdi type devices until there is no way left.

I'm going to do it anyway. These are widely available, cheap, and a very useful tool for anyone doing things such as you are doing. Perhaps you want to be able to get started with what you have on hand, but if you can afford it, I very much recommend that you order an FT232 or CH340 USB to serial adapter module now for your future needs. Last I checked, they were around $1 USD with free shipping from China on eBay. Buy a couple!

I do recommend you get one which uses the standard "FTDI header" pinout:

  • DTR or RTS
  • RX
  • TX
  • VCC
  • CTS
  • GND

That will allow you to plug the adapter right in to an Arduino Pro Mini, or many other boards that use this standard pinout. If you get an adapter with a non-standard pinout, you would need to use a mess of jumper wires to adapt it to the standard pinout. Some adapters don't even break out the DTR or RTS pin, without which you will need to manually reset the microcontroller at just the right time on every upload.

bitrux:
I have not yet been able to figure out how I can upload a sketch to the atmega328 on breadboard using Uno board as a bridge between arduino and PC.

You need to make the folllowing connections:

  • RX-RX
  • TX-TX
  • GND-GND

You can also power your chip from the Uno's 5V pin if you like.

You might think that the connections should be RX-TX, TX-RX, but this is not so. The reason is that the Uno's pins are marked according to the ATmega328P microcontroller's pins. But you aren't communicating between your chips and the ATmega328P. You are communicating between your chips and the USB to serial adapter on the Uno. That chip is connected to the Uno's ATmega328P with a RX-TX, TX-RX connection, so the Uno pin marked "RX" is connected to the USB to serial adapter's TX pin, and vice versa with the other pin.

Since you won't have the auto reset capability, you'll need to manually reset your chip just as the upload process starts. Note that this happens after the compilation finishes, so you can't reset when you click the "Upload" button in the IDE. You need to wait until you see the message in the IDE's console pane something like this:

Sketch uses 444 bytes (1%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

Then reset your chip.

It is very simple. Difficult is to find a recommendable tutorial.
Google for “Arduino uno as usb to TTL ”
You don’t need to remove the chip from the uno as some tutorials do. Instead, you put a capacitor between reset and ground to prevent the uno resetting while you attempt to load a sketch onto your breadboard Arduino.
Get power to your breadboard Arduino, then TX and RX (not crossed in this special case)
When uploading a sketch, treat the breadboard Arduino as a uno.

Edit
Post crossed with @pert

If I use my uno as usb , TTL by connecting reset and ground together then

Arduino TX to Standalone Atmega RX
Arduino RX to Standalone Atmega TX

And then 5 volt vcc and gnd,

Will this connection work?

bitrux:
If I use my uno as usb , TTL by connecting reset and ground together then

Arduino TX to Standalone Atmega RX
Arduino RX to Standalone Atmega TX

And then 5 volt vcc and gnd,

Will this connection work?

No. TX and RX are a special case here. Post #1 has considerable detail on this point.

TX -> TX
RX -> RX

Is it ok now?

Also, do I need crystals while doing it?

bitrux:
TX -> TX
RX -> RX

Is it ok now?

Also, do I need crystals while doing it?

Yes, if you are using a Uno as a USB TTL devices, then it is TX-TX and RX-RX. This is a special case. If you are using a purpose made USB TTL device, the labelling is different.
If you bought the chips with an Arduino bootloader, you will almost certainly need a 16MHz crystal and two 22pF capacitors.

Some people say that I need to refresh the Chip before programming or after programming.

So which statement is true?

I've never heard of the term "refresh" applied to a microcontroller. Please post a link to where you saw people saying these things.

Have you tried just wiring up the circuit and doing an upload?

pert:
I've never heard of the term "refresh" applied to a microcontroller. Please post a link to where you saw people saying these things.

Have you tried just wiring up the circuit and doing an upload?

Well, i saw those somewhere in articles which I read before posting this thread, also , that history is messed up with others in my browser, that u need to refresh chip when or after uploading a sketch via TTL
Don't remember which one so I can't give u the link, sorry.
Well, if I use arduino as TTL or CP2012 UART driver, will it work?
It would be great if I could use the arduino as TTL to perform this action
I haven't tried it yet, but will do soon as soon as I clear all my doubts .

You just need to dive in and give it a try. That's what Arduino is all about.

There's a nice tutorial here:

Make sure to add the pull-up resistor on the reset pin, the decoupling capacitors on the power lines, and the oscillator or crystal + load capacitors on the xtal pins.

bitrux:
Well, i saw those somewhere in articles which I read before posting this thread, also , that history is messed up with others in my browser, that u need to refresh chip when or after uploading a sketch via TTL
Don't remember which one so I can't give u the link, sorry.

There is a lot of bad information on the Internet. It's also very likely that you are misremembering it, since the term "refresh" does not apply in any way in this context. So if you can't provide a reference, then my recommendation is that you discard your vague recollection of some mysterious articles, since it is only serving to hold you back from progressing in your journey of learning.

bitrux:
Well, if I use arduino as TTL or CP2012 UART driver, will it work?

Please provide a detailed description of what you mean by "CP2012 UART driver"? Why do you you want to know that?

bitrux:
It would be great if I could use the arduino as TTL to perform this action

I think we've already explained quite clearly that you can use your Arduino to upload to your ATmega328P chips.

bitrux:
I haven't tried it yet, but will do soon as soon as I clear all my doubts .

The best way to clear your doubts is to roll up your sleeves and start breadboarding some circuits. You'll progress a lot faster doing that than waiting around for someone to answer all your questions on forums. It's good to be a bit cautious so you don't end up burning up all your electronics right away, but on the other hand you need to feel free to take some chances and experiment. Even if you destroy a couple chips along the way, the fun and learning you'll gain from it will be well worth the price!

Ok then my atmega , capacitor and crystal are 4-5 days away from me now , will ask again after some time, lemme give a try and , thanks so much.

OK, I didn't realize the parts were still in transit. It makes more sense to me now why you haven't just started breadboarding... because you don't have anything to breadboard!

I have the uno , bread board and some resistance and capacitor of 18 uf only right now, and do I need to upload a code just like 'Arduino as ISP' or something like this after connecting the Gnd to Reset of my uno?

bitrux:
do I need to upload a code just like 'Arduino as ISP' or something like this after connecting the Gnd to Reset of my uno?

No. You would only need to do that if you needed to burn the bootloader on the ATmega328P chips. Since you paid extra for the pre-bootloaded ATmega328P, you can skip that step and go straight to uploading over serial.