Atmega328P TQFP32

Hello.

I have a project that is using an 328P SMD TQFP32 and I want to program it from Arduino IDE and I want to also use the serial monitor.

For testing of my idea, I have connected the TX,RX,RST,GND and VCC of an DIP 328P to the Arduino and it worked. Then, I tried switching to my SMD 328P, which is mounted on a PCB, and I cannot program it, nor using serial monitor. My PCB had a 10K resistor holding uC's RST line at +5V and a 100nF cap to ground. I have removed them both and still it's not working.

Maybe someone can bring some light here, because I am stuck right now and I need the serial monitor for debugging.

Does the SMD part have a bootloader installed? Need that before the serial programming will work. Keep the reset pullup resistor for consistent operation. What else is connected? 16 MHz crystal wit 22 pF caps? 0.1uF caps from VCC, AVCC caps to Gnd? Reset switch to Gnd so that the chip can be reset and start up the bootloader code?

Thank you for the answer! I have burned the bootloader using ICSP and USBASP and now it works! The last day I have uploaded the Arduino-build hex code using 3rd party programmer(Khazama) and maybe that operation deleted the bootloader.

As we say, if it is working from the first try, we don't learn anything. Thank you!

Glad to help. Have done that to myself plenty of times!

I have encountered a problem:to upload a sketch from the Arduino IDE I need to burn the bootloader every time...If not, the RX blinks three times and then TX stays on and I'm getting "out of sync" error. Any ideas ? Thanks !

Got me on that one. I use the IDE's UNO bootloader on my 328P based projects, have not had issues.

If you burn a sketch using your USBASP programmer then it will wipe the bootloader and you'll have to reload it again to program via Serial.

Could this be what is happening?

As long as you continue uploading via serial then the bootloader should remain.

I have burned the bootloader using USBASP and then, on the first try, the sketch uploaded succesfully using tx/rx. Subsequent tries all failed. The wires from the Arduino to the target board have about 30cm, can this be an issue? Or the target board RST pull-down capacitor 100nF ?

Pulldown capacitor?

How exactly is this connected? It shouldn't be a 'pull down' as in connected to ground, but inline with the line to reset from your serial programming source. It's intended to allow a pulsed low to reach the reset pin from the DTR pin of the serial controller. If you have it connected wrong then maybe your target is being held permanently reset or not being reset properly for the bootloader to take the upload.

You could try manual reset. Remove the capacitor and keep the reset pin low on the target. Hit Upload on IDE and watch for it compiling the sketch. When it changes to 'uploading' allow the target reset pin to go high (via the 10k pull up resistor you should have on it). See if you can upload consistently, which will prove the bootloader is still there. The manual reset method is just about getting the timing right.

Hello!

On my custom made PCB the RST pin is decoupled to ground with a 100nF (bypassed with a switch for manual reset) and is set high via a 10K resistor. You are right, if I get the correct timing using the manual reset switch I can get it to program, but only with Duemilanove w/ ATmega328 bootloader.

The decoupling capacitor is there to provide a low-state to the RST pin at power-up, until the VCC stabilizes. It seems that the Arduino serial converter cannot properly reset the target board. Is there any need for a series capacitor? I have seen the Arduino schematic and it's already there...

YO9ICT: On my custom made PCB the RST pin is decoupled to ground with a 100nF (bypassed with a switch for manual reset) and is set high via a 10K resistor.

The decoupling capacitor is there to provide a low-state to the RST pin at power-up, until the VCC stabilizes. It seems that the Arduino serial converter cannot properly reset the target board. Is there any need for a series capacitor? I have seen the Arduino schematic and it's already there...

And that is precisely what you need to do - connect the capacitor not to ground, but to the RTS or DTR line on the USB to TTL chip.

The ATMega chips are designed to have built-in power-on logic and do not require a delay capacitor as such on the Reset line. In fact, IIRC it needs to be not present for the ISP to function.

Remove the capacitor you have between reset and ground. All you need is a series cap between the serial programmer DTR line and the Reset pin.

The series cap changes a Low signal from DTR into a pulsed signal that allows the pullup to bring Reset High again afterwards. The 'decoupling' cap you have connected is interfering with the timing of the pulse that the series cap effects.

Thank you for the tips. I have removed the 100nF cap and now it is working good. I haven't connected any series cap because it's already on the Arduino.

Another quick question: I don't have any AVCC to GND capacitor. How this can affect the ADC performance? I'm using all eight ADC inputs.

YO9ICT: Thank you for the tips. I have removed the 100nF cap and now it is working good. I haven't connected any series cap because it's already on the Arduino.

Just remember that you will need that series cap if using a separate USB>Serial adapter, if it doesn't already have one; e.g. most PL2303 or CP2102 modules.

YO9ICT: Another quick question: I don't have any AVCC to GND capacitor. How this can affect the ADC performance? I'm using all eight ADC inputs.

You should have decoupling on the AVCC and the Aref pins. Without it you may have issues with noise introduced via the power rails. If you find you get erratic ADC readings or other strangeness then the first suspicion would be the lack of decoupling. If you can add them then do.

tack: Just remember that you will need that series cap if using a separate USB>Serial adapter, if it doesn't already have one; e.g. most PL2303 or CP2102 modules.

A little clarification there - it is not the USB to TTL adaptor that has the series capacitor, the FTDI adaptors certainly do not have one. The capacitor becomes part of the interface on the ATMega board to whatever adaptor is used.

What the "bogus" PL2303 or CP2102 modules lack is having the RTS line brought out to the interface pins. On the six pin versions which were apparently put out by some poor sod who simply had no idea what he was doing, it is possible to modify them with some track-work to repair the blunder, but this has nothing to do with the capacitor; you do not add the capacitor to the USB to TTL module, it goes on the MCU board.

What I meant is that you can find some of these modules on eBay where they have been modified with the series cap on the correct line. Those ones will do the auto reset of the ATMega without the need to add the series cap on the board itself.

tack: What I meant is that you can find some of these modules on eBay where they have been modified with the series cap on the correct line. Those ones will do the auto reset of the ATMega without the need to add the series cap on the board itself.

I am not aware of a USB to TTL module - on eBay at least - which has been modified especially to incorporate a series capacitor for use only with breadboarded ATMegas, making it non-standard as an RS-232 interface.

I understand some have now been made with the corrected wiring and a pinout to match the FTDI module which does not contain such a capacitor in order that they do suit the Pro Mini and other ready-made boards all of which have the capacitor on the MCU board itself.

Can you point me to an example of such?

Paul__B: I am not aware of a USB to TTL module - on eBay at least - which has been modified especially to incorporate a series capacitor for use only with breadboarded ATMegas, making it non-standard as an RS-232 interface.

I understand some have now been made with the corrected wiring and a pinout to match the FTDI module which does not contain such a capacitor in order that they do suit the Pro Mini and other ready-made boards all of which have the capacitor on the MCU board itself.

Must say that the use of all those italics and stating you are not aware, does make it come across as a little condescending; i.e. you're not aware, therefore I'm making something up.

Paul_B: Can you point me to an example of such?

Of course,

http://www.ebay.co.uk/itm/USB-TTL-to-Serial-Converter-Module-CP2102-AUTO-RESET-ENABLED-for-Arduino-Project-/321112731162?pt=UK_Computing_Other_Computing_Networking&hash=item4ac3cf6e1a

tack: Must say that the use of all those italics and stating you are not aware, does make it come across as a little condescending; i.e. you're not aware, therefore I'm making something up.

Well, I am just pointing out the need for clarification. My italics are to point out a specific reference to breadboarded, "home brew" versions of the Arduino concept.

tack:

Paul_B: Can you point me to an example of such?

Of course, http://www.ebay.co.uk/itm/USB-TTL-to-Serial-Converter-Module-CP2102-AUTO-RESET-ENABLED-for-Arduino-Project-/321112731162?pt=UK_Computing_Other_Computing_Networking&hash=item4ac3cf6e1a

OK, so I would really like to confirm that you have purchased one of these and observed that it actually has an 0.1µF capacitor added (because I cannot see why it would)?

While that site certainly goes to great length and font size to stress that it is "Auto-Reset Ready" - and presumably is in the sense that it will emulate the FTDI module, since it does not mention such a capacitor and since the capacitor would only be required to be added for "breadboard" and possibly some of the Adafruit variants, I am naturally inclined to presume that it would not.

If we can comprehensively verify this one way or the other, then all of us can give more useful advice in future.

Jeesh, you are hard to convince!

Yes, I've bought one before. Yes, it has been modified to include the 0.1uF cap to provide a direct AVR reset pulse on a pin from the module. As it clearly states, it will work with 'barebones' set ups without the need to do the manual reset.