USB 2 Serial Converter to program an ATMEGA328P

Hello,

I have recently brought a USB 2 Serial converter from Arduino USB 2 Serial Micro.

I have built a breadboard arduino with a bootloaded ATMEGA328P which I can already program by using an Arduino Uno as an ISP.

I would now like to use this serial converter but it says I need to install a windows driver. It provides me with a ‘Arduino USB2Serial.inf’ file and I am not sure where this should go?

I have attached a schematic. The 1k resistor is actually 10k.

USB CONVERTER ---------> ATMEGA328P

RST -----------> RST
RX -------------> TX
TX --------------> RX
GND ------------> GND
5V --------------> VCC

Capture.PNG

Is there also a .sys file in with the .inf file? Also looking at your .png, I'm thinking that 1k pullup is a bit strong - I'd suggest a 10k.

justjohn:
Is there also a .sys file in with the .inf file? Also looking at your .png, I’m thinking that 1k pullup is a bit strong - I’d suggest a 10k.

When I downloaded the zip file from the link above, it just has a .inf file inside. That is a 10k resistor my bad. I tried programming my ATMEGA328 but it says sync error of some sort?

“I have built a breadboard arduino with a bootloaded ATMEGA328P which I can already program by using an Arduino Uno as an ISP.”

Make sure you re-load the bootloader after using the Arduino Uno as an ISP to load sketches. The bootloader is wiped when using ISP to load sketches.

If the UNo is working, I think you already have the .inf file loaded .

I wanted to answer this sooner, but was locked out, perhaps because I’m new here and posted too much too soon.

I agree with kprims.

I also had a look at the .inf file. FWIW, that is an abbreviation for “information” as it just contains information telling the window installer what driver to load and some specifics concerning the install process. There is often a .sys file with a .inf file (sometimes other files too) unless it uses a file that comes with Windows, as yours does (usbser.sys already on your system).

justjohn: I wanted to answer this sooner, but was locked out, perhaps because I'm new here and posted too much too soon.

I agree with kprims.

I also had a look at the .inf file. FWIW, that is an abbreviation for "information" as it just contains information telling the window installer what driver to load and some specifics concerning the install process. There is often a .sys file with a .inf file (sometimes other files too) unless it uses a file that comes with Windows, as yours does (usbser.sys already on your system).

Ah okay great. I need to reset the drivers for my USB adapter because I selected update driver from disk in device manager and selected the inf file that I downloaded.

As for burning the bootloader. Say I flash a program that will transmit data over serial so I can read it over serial monitor. Once I flash the program using the ISP, will the program be removed if I then flash the bootloader on it straight after?

Also when I was trying to program my ATMEGA328P on the breadboard using the USB2Serial with rx and tx lines, it wasn't working and giving me a sync error, I'm presuming this is because it had no bootloader on it or something?

Nurul15: Ah okay great. I need to reset the drivers for my USB adapter because I selected update driver from disk in device manager and selected the inf file that I downloaded.

As for burning the bootloader. Say I flash a program that will transmit data over serial so I can read it over serial monitor. Once I flash the program using the ISP, will the program be removed if I then flash the bootloader on it straight after?

Flashing any program via ISP erases whatever was on it before (including any bootloader)

Also when I was trying to program my ATMEGA328P on the breadboard using the USB2Serial with rx and tx lines, it wasn't working and giving me a sync error, I'm presuming this is because it had no bootloader on it or something?

tx/rx is not sufficient. Also connections further up are wrong.

You need to connect the DTR pin of the serial adatper to one side of a 0.1uf ceramic cap and the other side to the reset pin, and a 10k resistor between rst and vcc.

There is no RST pin on standard usb serial bridge IC so not sure wtf that is connected to!

DrAzzy is more observant than me, since I didn't notice the lack of connecting of that reset line. You will need to connect that. The reset line on your USB2Serial adaptor goes to the reset pin on your board, also making use of the cap and resistor that DrAzzy mentioned. A serial bridge such as FTDI's FT232R has a DTR pin which would be wired the same way as you'll be wiring that Reset pin on your USB2Serial board - the cap and resistor thing.

Here's an explanation of how the bootloader works: The bootloader allows the part to be programmed using the arduino IDE through the serial lines, in the typical way as with a USB cable connected to the arduino - the arduino has the converter on the board. Or with an adaptor such as you're using. The ISP uses the SPI pins. If you program either or both using the ISP, one will overwrite the other since the program will go where the bootloader usually goes. But if you program the bootloader and then the program through the serial pins, the bootloader won't be overwritten since the program will be written by the bootloader. If the only way you're going to program is using the ISP pins, then you really don't need the bootloader. Overall the bootloader and serial thing is easiest, so I'd suggest burning the bootloader first, and thereafter use only the USB2Serial adaptor to program you app code.

If you open up one of the bootloader files such as "optiboot.c" and it's associated files, or whatever loader your board uses, (they're somewhere in one of the folders with your arduino software installation), you'll see how it writes the program coming into RX, and provides feedback on what's going on by way of the TX (that's what you see below the code when writing the program as in verbose mode). You can even modify it and rebuild a new one if you want to do something special since the makefile and all is right there with it. The files are well documented and easy to work with.

A friend of mine said I could share an eagle screenshot of one of his boards showing how the reset is routed to an FTDI chip (the blue pads in the pic), with the trace to it barely visible beneath one of the mounting pads for the usb cable connector. He said the pin marked reset on one of those pads is actually the DTR pin coming off the chip. With this adapter the cap and resistor are on the board. The adapter has spi outputs also, but those are just there because the programming inputs for his boards have this configuration so they can be programmed either way, via serial or spi .

justjohn:
A friend of mine said I could share an eagle screenshot of one of his boards showing how the reset is routed to an FTDI chip (the blue pads in the pic), with the trace to it barely visible beneath one of the mounting pads for the usb cable connector. He said the pin marked reset on one of those pads is actually the DTR pin coming off the chip. With this adapter the cap and resistor are on the board. The adapter has spi outputs also, but those are just there because the programming inputs for his boards have this configuration so they can be programmed either way, via serial or spi .

Hi John,

Thank you for the excellent help. I have attached my circuit and a printscreen of what is occuring. I first burned a bootloader onto the ATMEGA328P by using the Arduino Uno as an ISP. This was successful. I then connected the USB2Serial converter and tried to upload a program but it is giving me an error. Any ideas? I have put a 0.1uF capacitor between DTR of the USB2Serial and RST pin of the ATMEGA too.

Breadboard: https://drive.google.com/open?id=1ckTWlZeIB9B1MlJppCzZ-qaNTRJAG8hZ

justjohn: A friend of mine said I could share an eagle screenshot of one of his boards showing how the reset is routed to an FTDI chip (the blue pads in the pic), with the trace to it barely visible beneath one of the mounting pads for the usb cable connector. He said the pin marked reset on one of those pads is actually the DTR pin coming off the chip. With this adapter the cap and resistor are on the board. The adapter has spi outputs also, but those are just there because the programming inputs for his boards have this configuration so they can be programmed either way, via serial or spi .

Oh! Never mind I've solved it! I just had to select Arduino Nano as the board instead of Arduino Uno! Thank you so much!

Ha, ha. . . great to hear that. :slight_smile: