Pages: [1] 2   Go Down
Author Topic: Atmega328P TQFP32  (Read 1599 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 !
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 569
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 569
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

NSW Australia
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3662
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 569
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 569
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

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.
Logged

NSW Australia
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3662
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1] 2   Go Up
Jump to: