# Arduino Programmer

#### AtomSoft

##### Well-Known Member
Ok i want to make my own arduino boards but am kind of lost when it comes to programming it. I have a AVR Dragon so i know i can program a bootloader on it but the issue isnt that.

I want to be able to program my stuff using the Arduino IDE and simple on board components like a serial to usb connector.

Now im looking at the Arduino Uno schematic (r3) and need to know... does the ATMEGA16U2-MU(R) act only as a USB to UART device?

If i replace this with something like a FTDI or CP2102 would i still be able to program the arduino?

http://www.electro-tech-online.com/custompdfs/2012/04/Arduino_Uno_Rev3-schematic.pdf

My main questions are...

1. Does the ATMEGA16U2-MU(R) translate USB commands to program the AVR?
2. Or Does the ATMEGA16U2-MU(R) translate the USB commands to UART for the MAIN AVRs bootloader to program itself?

Last edited:

#### Ian Rogers

##### User Extraordinaire
Forum Supporter
You can always buy the chips in quantity, with the bootloader already installed... This is the way "TinyClr" (.net) operated.. The chips weren't much more with the bootloader. Probably thinking about it... To program the chips with a bootlader was a lot quicker for them.

#### AtomSoft

##### Well-Known Member
Yeah thats the plan but i want to make a PCB some custom Arduino stuff. And i want to make sure all i need is a usb to usart cable...

Oh wait! I have a Arduino here that means the chip has a bootloader already. Ill try to make my own usb to uart and test on that... wow silly me!

#### leftfield95

##### Member
Hi Jason,

If you already have an arduino you can use that to load a bootloader to your new ATMEGA168 etc. Then all you need is a usb-ttl adaptor like this

http://www.ebay.co.uk/itm/USB-2-0-T...uting_CablesConnectors_RL&hash=item45fc6f93a2

Note that older versions of arduino used a manual reset and newer versions use an auto reset, so that the new sketch runs automatically after loading. The usb-ttl adaptor linked above includes the reset line as well as the basic tx/rx used by the bootloader.
I haven't used my arduino for a while so can't remember the exact settings in the arduino IDE you need to use when using non FTDI usb ttl adaptors.

Regards,
Leftfield95

#### AtomSoft

##### Well-Known Member
Ok this is the dilemma now:

Code:
Binary sketch size: 1026 bytes (of a 32256 byte maximum)
avrdude: stk500_getsync(): not in sync: resp=0x00
Its a simple blink example but cant program it via Serial port... now what? I tried connecting DTR so Reset as well. But no go...

What do i select as programmer? Or will this only work with FTDI usb to uart?

If so how would i make my own driver for CP2102?

#### AtomSoft

##### Well-Known Member
I Actually sell something like that.
http://atomsofttech.com/shop/index.php?route=product/product&product_id=97

But its not working for this. I tried everything from settings in Device Manager to reversing the TX RX Pins.

When programming i see the Uno reset but i still get the error and nothing is uploaded. So my idea or well my only option is to use the same IC as in the Uno: ATMEGA16U2

But that seems to be out of stock everywhere but Digikey and cost almost $4 there. I guess its my only option so ...$4 it is

#### leftfield95

##### Member
Are you trying to program a sketch into your old bootloaded arduino chip from your aduino board, but using a diy serial interface and the chip on breadboard ?

If so you need to tell the arduino IDE what type of board your trying to emulate ie "Arduino Uno", "Arduino Duemilanove", "Arduino Diecimila" this will tell it how to program the sketch.

#### leftfield95

##### Member
OK, I see you have an UNO based chip, unfortunately I have never used one of those.

The older style Arduino that I have used were OK for programming via the FTDI or CP2102 chips, you could try programming an older bootloader onto your arduino chip something like the "Arduino Duemilanove".

A couple of IDE files you may find interesting are boards.txt and programmers.txt they show how the IDE treats the various boards and what bootloader it expects for each.

Last edited:

#### AtomSoft

##### Well-Known Member
Ok thanks for the tip. I went into a directory: arduino-usbserial

which has the source for the atmega16u2 part... do you think it would be hard to edit this code for a AT90USB162 ? I have 3 of those ICs on hand in TQFP but still worthy of a try. I never did any AVR coding that i can remember but i guess this is worth a shot. Also the AT90USB162 cost the same as a CP2102 so would be perfect!

#### leftfield95

##### Member
I thought the UNO used an ATMEGA8 for its usb to serial convertor, I guess the latest revs have gone to the higher spec chip.

As for modifying the code for an AT90USB162, I'm not sure, I don't like C at the best of times.

My current setup as well as lots of Arduino Duemilanove clones, is to use one of these ;

http://www.ebay.co.uk/itm/XINO-Basi...715?pt=LH_DefaultDomain_3&hash=item4ab5dcbe9b

Which I use with the CP2102 board linked previously. But I use an older version of firmware on them, than the more upto date UNO use.
The version I use seems to work OK, so I've never bothered with the newer stuff. I will try and dig out the boards later and have a play, probably 4 or 5 hours.

But at the moment I have to go out.

#### AtomSoft

##### Well-Known Member
Thanks and that little board is awesome!

Ok Let me give you a example of what i want to do.

Lets say you have a Arduino and Ethernet shield... I want to basically combine them into 1 PCB but still be able to program it like a arduino. Thats why im thinking about just spending the extra \$1 and change for the ATMEGA16U2. And just program it with same firmware on arduino uno. This way its completely compatible.

#### leftfield95

##### Member
OK, I've managed to upload a sketch (i hate that word, Its a program people) using the onboard FTDI and an external CP2102 module, with both an UNO and Duemilanove bootloader onboard.
I had no problems with any of the four combinations, you just have to make sure the COM port is set correctly, ie. baud rate and handshaking.

The previous link I gave for the CP2102 module is wrong, this is the module I have, it has access to the DTR line, along with all the other handshake signals.

It looks like any USB to TTL serial adaptor should work, I am going to try this next.

I see what you're trying to do with the combined PCB, I think I've seen them already from a couple of sources, a DIY one is here.

http://www.instructables.com/id/A-credit-card-sized-Ethernet-Arduino-compatable-co/

#### leftfield95

##### Member
For the UNO bootloader is needs to be set at 115200.

For the Duemilanove it needs to be 57600.

Thats according to the boards.txt file, both are with hardware handshaking if you want the auto-reset to work.

So if you try and upload with a serial link that cant do 115200 reliably on a UNO bootloader it may not work.

#### be80be

##### Well-Known Member
All you need is TX RX and CTS

And your usb to serial adapter to say I'm a com port for the uno

The ATMEGA16U2 can do two things It's a USB bridge and a AVR programmer with right code loaded

The '16U2 firmware uses the standard USB COM drivers, and no external driver is needed. However, on Windows, a .inf file is required.
AND for programmer
The ATmega16U2 (or 8U2 in the rev1 and rev2 boards) firmware source code is available . The ATmega16U2/8U2 is loaded with a DFU bootloader, which can be activated by:
On Rev1 boards: connecting the solder jumper on the back of the board (near the map of Italy) and then resetting the 8U2.
On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB line to ground, making it easier to put into DFU mode.
You can then use Atmel's FLIP software (Windows) or the DFU programmer (Mac OS X and Linux) to load a new firmware. Or you can use the ISP header with an external programmer (overwriting the DFU bootloader). See this user-contributed tutorial for more information.
There auto baud rate you can set the port to most any rate.

Mine is at 9600

Last edited:

#### AtomSoft

##### Well-Known Member
Thanks Burt... Are you sure its CTS ? It resets ok with DTR but still has a sync issue. I tried adjusting the baud but no go

How would my adapter say "im a com for uno" ? lol

It shows up as COM3 which is correct but no go so far

#### AtomSoft

##### Well-Known Member
OMG lol i think i know the problem... its me being lazy. Instead of placing my IC from arduino on a breadboard i am trying it in the Uno board so the other IC is mixing or corrupting the data. I tried it from the UNO itself and it doesnt work with the UART pins being used. If i remove my USB to UART the UNO is programing as normal. So ill try it on a breadboard alone and write back soon.