ATMega328 board programming issue

I am having a problem with a board I did not design but all my research seems to indicate that this is done correctly. I am having an issue uploading the built code to the chip unless I bridge the connection over the capacitor that is inline with the pin1 reset pin. Here is the board where you can see the cap just before pin 1:


And here is the design in eagle to make it more clear:

The board is using the ftdi ft232rl uart to USB. I can not seem to program the chip unless I take a screwdriver and bridge the connection on the capacitor C5, and then it works fine.

Has anyone seen this before? Is the cap I have bad? Did I do something stupid?

Thanks,
-Daniel

Hi, welcome to the forum.
Please show us the schematic.

Even without schematic I can spot a few problems:

  • There should be decoupling capacitor(s) near the ATmega chip.
  • There should be a pullup resistor of 10k (and preferably a diode to 5V) at the reset pin.
  • AREF seems to be connected to 5V. That is wrong.
  • Pin 13 (SCK) is not available at a connector. So uploading a bootloader is not possible ?

The Arduino Nano uses the FTDI chip, compare the schematics : https://www.arduino.cc/en/Main/arduinoBoardNano
The pinmapping could be useful : https://www.arduino.cc/en/Hacking/PinMapping168

Peter_n:
Hi, welcome to the forum.
Please show us the schematic.

Even without schematic I can spot a few problems:

  • There should be decoupling capacitor(s) near the ATmega chip.
  • There should be a pullup resistor of 10k (and preferably a diode to 5V) at the reset pin.
  • AREF seems to be connected to 5V. That is wrong.
  • Pin 13 (SCK) is not available at a connector. So uploading a bootloader is not possible ?

The Arduino Nano uses the FTDI chip, compare the schematics : https://www.arduino.cc/en/Main/arduinoBoardNano
The pinmapping could be useful : https://www.arduino.cc/en/Hacking/PinMapping168

Here is a link to the schematic in PDF form on my website:

I bought the chips from digikey with the bootloader - and they are fine. I just have problems flashing them with the program unless I bridge the two leads coming through where the capacitor C5 is. Everything seems to indicate that the 100nf cap is how to use the DTR pin coming from the ftdi chip. Do I need to add a resistor there perhaps?

Looking at the Nano schematic is a little confusing - there is a .1uf/100nf cap going to reset but is there also the switch to ground and resistor to +5V?

Pull-up resistor on RESET is required. It is keeping RESET high during normal operation.

Budvar10:
Pull-up resistor on RESET is required. It is keeping RESET high during normal operation.

I do not have any issue with it randomly resetting though. It seems that when a reset button is there, you need a few more parts, but I don’t have a reset button. Where does the pull up go, after the cap like in this?

It seems to program more reliably if I plug it in and wait a little while before trying to upload the program. If it fails and I jump the pins of the cap c5 it will then pretty much work. I’m trying to understand what I’m doing there that’s causing it to finally work…maybe shorting the cap so the voltage is low?

That schematic with the 10k and diode for the reset is perfect.
It doesn't have to do with working more or less, it has to work well, don't mess around with shorting a capacitor. you will end up in so much trouble, you don't want that.
The diode is optional, but without it, the bootloader might get corrupted with a high voltage spike when the DTR/reset is connected.

The 4 things that I mentioned still stand.
I can add number 5: The 7805 needs decoupling capacitors of 100nF on both sides (maybe not on both sides, but it is better).
And number 6: You need to be able to burn the bootloader. When everything is soldered in place, you can't afford to throw all the boards away, because they happen to have to wrong bootloader.

Your board seems to be the first prototype to do some tests.

Hi,
Socket mount all the ICs if its a prototype.

Tom.... :slight_smile:

Tom - I am using sockets for the atmega.

Peter - the 7805 does have caps on each side, marked C12 and C14, so I’m not sure if you missed those.

Also - I am not selling these completed. It is a community design and I am only trying to get a run of boards so others can make one - a chip with an arduino bootloader is one of the requirements and I am not going to add a programming header. You can get the chips so cheap with the bootloader already installed it’s not worth the hassle.

As for the other items in your list:

There should be decoupling capacitor(s) near the ATmega chip.

Can you be more specific for this? Would C6 be a cap between VCC and ground and be what you’re talking about?

There should be a pullup resistor of 10k (and preferably a diode to 5V) at the reset pin.

This is where I am a bit confused. I found the picture above but along with that it warns it may reset too often when the serial connection is opened. The FT232rl pin DTR should be +5V until active, when it then drops to low. So why does it only work when the board has been plugged in for a minute or if I short the cap? Does it just take a little while for the cap to charge or something for the pulse to work?

AREF seems to be connected to 5V. That is wrong.

I think this is correct as we need to make sure we have a valid voltage reading because the whole point of this board is measuring power.

Pin 13 (SCK) is not available at a connector. So uploading a bootloader is not possible ?

As stated before, a chip with bootloader is a requirement for this project. Hams are not always the best with technology and making this a requirement solves the bootloader flashing issue.

I prefer 100nF capacitor at VI and VO of the 7805. You can add larger elco as you like, which are now 1uF and 10uF. If I remember it right, the 100nF at the output is more important.

A programming header might not be needed, as long as you are able to burn a bootloader one way or the other.

C6 is a decoupling capacitor. But it should be 100nF and it should be near the ATmega328P chip.

The reset circuit is one thing… opening a serial communication is another thing. I think that warning was bogus, or misunderstood.
Please use that 10k and the diode. That is how the reset circuit should be.
At the moment you reset circuit is not okay, and that is why it is not working very well.
Without the 10k it will not work (or only now and then). Without the diode you might corrupt the bootloader (I learned about that here: http://forum.arduino.cc/index.php?topic=288600.0 ).

When you open the serial communication, an Arduino board resets. That is to be able to upload a sketch.

I say it again: connecting 5V to AREF is wrong.
When you select the internal voltage reference, the AREF is internally connected to the 5V. That is also the default for the Arduino code.
If you would like to select the internal 1.1V reference for more accuracy for low voltages, then there will be a shortcut between the internal reference and the 5V at AREF. That might damage the ATmega328P.

Peter_n:
The reset circuit is one thing... opening a serial communication is another thing. I think that warning was bogus, or misunderstood.
Please use that 10k and the diode. That is how the reset circuit should be.
At the moment you reset circuit is not okay, and that is why it is not working very well.
Without the 10k it will not work (or only now and then). Without the diode you might corrupt the bootloader (I learned about that here: http://forum.arduino.cc/index.php?topic=288600.0 ).

When you open the serial communication, an Arduino board resets. That is to be able to upload a sketch.

I will see if I can try to do this on my board as a test. Gonna be a little ghetto but will at least make programming work more reliably.

Peter_n:
I say it again: connecting 5V to AREF is wrong.
When you select the internal voltage reference, the AREF is internally connected to the 5V. That is also the default for the Arduino code.
If you would like to select the internal 1.1V reference for more accuracy for low voltages, then there will be a shortcut between the internal reference and the 5V at AREF. That might damage the ATmega328P.

I can't seem to find where this could damage it. From the datasheet it just says that if you connect AREF that the value from AREF will be used.

http://www.atmel.com/images/atmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet_complete.pdf

Section 24.9.1
The internal voltage reference options may not be used if an external reference voltage is being applied to the AREF pin.

However if using analogReference(external) there is no possibility of shorting to the 1.1v source?

Correct. If you connect a voltage to AREF, then you should use analogReference(EXTERNAL) before calling analogRead(). That is okay and nothing gets damaged. However, you won’t be able to switch to the 1.1V internal reference anymore. Also if you try an example sketch without the analogReference(EXTERNAL) then things can get damaged.

Using the internal 5V and a capacitor of 100nF at AREF is how it should be done. There is no advantage to use external 5V to AREF.

According to the datasheet (with AVCC they mean the internal 5V): “If the user has a fixed voltage source connected to the AREF pin, the user may not use the other reference voltage options in the application, as they will be shorted to the external voltage. If no external voltage is applied to the AREF pin, the user may switch between AVCC and 1.1V as reference selection”.