Atmeg328p can be programmed using USBasp programmer, but is out of sync when using FT232RL

Hi everyone. For a university project, I have created a custom PCB using the Atmega328p. I have based circuit design on the Arduino nano V3.3 schematic. The board layout near the FT232RL and Atmega328p looks like this (I've not shown the bottom copper trace for clarity, but it's mainly just a ground pour):

image

Using the ISCP headers, I am able to burn the bootloader and upload sketches using a USBasp programmer. After burning the bootloader, I was hoping to program the board in the same way that I would a UNO/Nano, but I always get an out of sync error:

could this simply be a problem with my board layout? On reflection, it does look like the decoupling capacitors for the FT232RL are a bit far from the Vcc/GND connections... Could this be what is causing the out of sync error?

Please post the schematic.

When you do that it erases the bootloader. So you must do another "Burn Bootloader" before you can go back to uploading via the FT232R again.

1 Like

Hi in0, i see. I have tried uploading a sketch using the FT232RL straight after burning the bootloader but still no luck :confused:

Here is the connection for the USB and FT232RL:

and here is the connection to the Atmega328P:

Compare your connection between DTR (FTDI) and RESET (328P) with that of a Nano (or Uno); there is a capacitor missing.

do you mean this capacitor going from pin 2 of IC1 to pin 29 of IC3?


as far as I can tell I still have it! (although it is hard to see on my diagram due to the two 1K resistor being right above it)

or am I being blind? :sweat_smile:

You're right. In that case I do not know.

I was also suspicious of the auto-reset circuit, which was why I requested to see the schematic.

I note that you are using a 47K resistor for the pull-up on the reset pin. I believe the auto-reset circuit is a bit sensitive to the value of this resistor. I see a 1K resistor on the Nano's schematic, but the more common value for DIY designs is 10K and I know from experience that works fine.

I will recommend you to try an experiment to determine whether the reset is the cause of the failure: try any upload with a manual reset.

When you are resetting manually, you need to get the timing right. If you press the reset button too early, the bootloader will have already timed out by the time the upload starts. The tricky thing is that when you press the "Upload" button in the Arduino IDE, it first compiles your sketch before starting the actual upload. So you need to wait until after the compilation finishes before pressing the reset button. The way to get the timing right is to watch the black console window at the bottom of the Arduino IDE window. As soon as you see 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.

press and release the reset button. If you don't have a reset button on your board, then just connect the reset pin to ground momentarily.

I see, I will try changing the 47 K to a 10 K and see how that does! I'll also try the manual reset myself to see if that helps once I am back in work tomorrow

Hi in0,

I replaced the 47 K with a 10 K and I've double-checked that it is a 100 nF capacitor from DTR to reset. Here is the waveform I get at the beginning of the upload:

so it looks like the reset circuitry is working. Unfortunately, I keep getting the out of sync error and it also didn't work after using a manual pull-down push button on the reset pin :confused:

Since then, I have also performed the loopback test which actually works! Which confirms that the FT232RL circuitry works fine and that the correct data is being transmitted to the Atmega328p from the FTDI.

After talking to another technician at my university, he said that I should use the USBasp to upload a simple sketch to transmit the words hello to the serial monitor on the PC. That way, if my PC cannot pick up the word hello, then there may be something wrong with the RX/TX circuitry between the Atmega328p and the FT232RL.

I'm going to have a look at this now and I'll post the results here and ho[efully that will shed some light on the issue!

Update: not sure if anyone is keeping up to date on this but I have found a couple of errors in my design that I thought would be useful for others.

The first big error was that I was using an 8 MHz crystal as opposed to a 16 MHz crystal. When I switched to the 8 MHz crystal I was able to get Serail communication to work properly, although I could still only upload code to the Atmega328p using the USBasp ICSP.

My second error is in not including a reset switch on my design... I have re-ordered the PCB and added a reset switch and I will see if I can get the upload to work using the correct frequency and using the reset button

Did you use 8MHz bootloader then?

I switched to a 16 MHz crystal, thankfully there were some in my lab with the same footprint as the 8 MHz crystal. So now, with a 16 MHz crystal I can get messages over the serial monitor at the correct baud rate, but I still get an out of sync error whenever i try to upload a code directly using the USB/FTDI

There are just few simple things you need for uploading.

  1. Correctly powered chip, all VCC and GND must be used. Decoupling on each power pin is strongly recommended. 100nF capacitors for ATmega328P is standard choice, 1uF is way too much. Capacitors should be as close to the power pins as it is possible.
  2. Clock. Standard Arduino with ATmega328P uses an external crystal. Check the clock signal.
  3. Reset circuit: 10k pull-up resistor to RESET, cca 100nF from RESET to DTR signal. Nice to have a diode in backward direction, parallel to 10k resistor which cuts overshot from reset pulse.

This is the textbook. I do not understand why you are not following UNO R3 schematics. Use of FT232 is not problem.

Arduino uses 16MHz clock, so the bootloader and upload settings in the IDE for 16MHz. Do not forget the fact that if you've uploaded the sketch via ISP, the bootloader is removed. You have to upload it again in such case.

There is not problem with e.g. 8MHz crystal but the bootloader and all settings must be for 8MHz. Bear on mind that the main clock signal defines clock for serial communication.

1 Like

perfect! turns out I was wiping the bootloader by uploading sketches via the ICSP :sweat_smile: thank you everyone for all your help!

Good! :ok_hand:

1 Like