ATmega 328P, why won't you talk to me?

Go To Last Post
22 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


 

Hi everybody, first time post so it's probably in the wrong area and (hopefully) brain-dead simple to somebody with a little more experience than me. I'm working on some custom arduino uno based thing, which is what got me hopeful it might work right the first time. I've done bare-metal programming before, but this is my first time working with an SMD uc on a bespoke PCB and I'm really struggling to even figure out what might be going wrong so I can deal with it. Here's what I've done so far:

  1. Assembled first PCB
  2. Utterly borked it (reflow station too hot, too much paste, insufficient blood sacrifice)
  3. Assembled second PCB
  4. Checked for shorts
  5. Checked voltage regulators are working
  6. Setup an arduino as an ISP (is that even how to use that in a sentence?)
  7. Attempted to burn arduino bootloader (end goal is an arduino-ecosystem compatible widget)
  8. "Device signature = 0x000000"
  9. Burnt a known-good arduino, upload worked
  10. Realised I had shorted the reset button, desoldered it
  11. Realised I had flipped an op-amp driven by the ATmega, cut the trace
  12. "Device signature = 0x000000"

 

Here's the schematic for the uc. I'm not trying to reinvent the wheel here, so this is more than 90% just the uno schematic. Which is why I'm so stumped why it's not working.

 

 

I've been bashing my head against this wall for a few hours and am a bit stumped on where to go next.

  • I used a hot-air gun to reflow the paste, could I have cooked the ATmega?

     

    • Counter - this is not my first smd pcb assembled like this, and I've never cooked a chip before but by no means an expert
  • Just a bad chip?
    • Counter - what the hell do I do about it, and how can I check an SMD-uc before committing to assembling a full board?
  • I'm having issues with my usb-uart converter too. Could it be related?
    • Further info - It's a CP2102N. usb power and all the traces seem fine, but similar to the uc I'm having issues pin-pointing what is actually going wrong and why I can't get any response from it
  • I've seen a lot of comments that it's likely an oscillator thing, which has me completely stumped as that's all-new to me. I'm using a Murata ceramic resonator, similar but not identical to the one in the arduino uno schematic (Y2). Do you think that's what it could be?

 

It's been a bit disappointing after all the time and effort spent designing, then ordering the pcb and all the parts, then all the hours assembling my first batch to be stuck at this wall so hopefully it's something easily fixed versus a total redesign.

 

Thanks!

 

Edit: Full Schematic

 

Last Edited: Mon. Aug 3, 2020 - 07:12 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is there anything else connected to miso, mosi and sck?

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

I used a hot-air gun to reflow the paste, could I have cooked the ATmega?

Maybe---easy does it...don't crank it up to max ...will be way too hot.  Measure the temp  and adjust properly before applying heat. 

 

with a fresh chip, make sure you program at no more than about 100KHz (250 absolute max)

 

ground should point DOWN, not sideways.

 

why would you have any concern about the osc, since it is using the internal osc???

 

Have you tried using an actual AVR programmer?  what happened?   Don't try to build a programmer AND a new board to be programmed at the same time!!!!

 

Use either a known working programmer, or a board that has been previously successfully programmed 

 

edit:  I see step 9  Burnt a known-good arduino, upload worked ...so you are in much better shape.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Fri. Jul 31, 2020 - 09:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to the Forum.

You are off to a good start.

 

If you are using another micro as an ISP programmer then the USB interface just doesn't matter at the moment, so focus on the micro for now.

 

I believe you said you used your ISP programmer to program another micro, so that is good, as it means that that part of your set up is working.

 

As mentioned above, a new micro runs on its internal RC Oscillator, at a much slower clock speed than the 16 MHz clock that uses the external resonator.

 

You have to be able to read the chip's signature first, stat is step one.

Then you can --> very carefully <-- change the Fuses to have the micro run on the external 16 MHz resonator's clock source.

 

The programming speed must be < 1/4 the micro's clock, so you will have to make sure that your ISP programmer is attempting to program the chip at a very slow speed.

How you set the speed depends upon the software it is using, but go track this down.

 

Please post a good photo of you PCB, it may help spot any other issues that might impact your success.

 

JC

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

BTW, what is Pin 33, DAP, stand for?

I assume that is the Ground pad on the bottom of the chip?

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is no reset\ circuitry shown.  There should be a  pull-up resistor on reset\, about 10K ohms.   And where is the ISP header?  And what is this pin 33 "DAP" thing in the corner?

  

Get out your sewing needles, your alligator-clip jumpers, and your DVM continuity checker.  Attach the sewing needles to the continuity checker's probes using alligator-clip jumpers.   Put the sharp tip of the sewing needle onto the pin of the IC that is soldered onto the PCB, and the other sewing needle onto the pin of the ISP header in order to verify the connection between the AVR and the ISP header.

 

Stop futzing around with a tiny MU packaged mega328p and a custom PCB.  Anything that is done with a Mega328p should be done with an Arduino PCB, either a Nano or a Pro Mini.  The Pro mini cost about $3 USD and is a fully-tested standardized, bootloader-based AVR hardware-development platform.  Doing-It-Yourself with a mega328p is not going to get you anything cheaper or better than the Nano/Pro Mini.  

 

Life is too short to spend trying to figure out why your custom PCB Mega328p-based application isn't working.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pine wrote:
Realised I had flipped an op-amp driven by the ATmega, cut the trace

 

Is the output of the op-amp to the SCK trace like on an UNO? Ohm the trace out and make sure it still goes from the programing header to the chip.

 

https://content.arduino.cc/assets/UNO-TH_Rev3e_sch.pdf

 

I had a problem with my op-amp setup several years ago, where I discovered (eventually) that not powering the op-amp
(cut the power trace to it) caused it to hold the SCK pin low through its clamp diodes.

 

Simonetta wrote:
Doing-It-Yourself with a mega328p is not going to get you anything cheaper or better than the Nano/Pro Mini.  

 

That feels me with the urge to defecate.

my projects: https://github.com/epccs

Debugging is harder than programming - don’t write code you can’t debug! https://www.avrfreaks.net/forum/help-it-doesnt-work

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

BTW, what is Pin 33, DAP, stand for?

I assume that is the Ground pad on the bottom of the chip?

 

JC

 

Yep, that's correct. I'm using that -MU package on the board I'm currently working on.

 

I've never managed to cook a chip and I do all my SMT assembly on the kitchen stove (pun unintended). I even changed a QFN24 CP2102 the other day with a non-adjustable heat gun. You have to pretty brutal to kill a chip.

 

Re the design, I'd like to see a 10K pull-up on the /RESET line, and maybe a 100nF to ground. In fact, I don't see /RESET attached to any of the external headers.

Last Edited: Fri. Jul 31, 2020 - 08:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And the Reset\ signal is a critical part of ISP programming, so perhaps that is the underlying reason the OP is having difficulty.

 

and I do all my SMT assembly on the kitchen stove

 

Me too!

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

And the Reset\ signal is a critical part of ISP programming, so perhaps that is the underlying reason the OP is having difficulty.

 

and I do all my SMT assembly on the kitchen stove

 

Me too!

 

JC

 

Electric glass-top ? All this pro tools nonsense is a subtle ruse to keep manufacturers in business and engineers in jobs ;) A pair of tweezers and a 40x jewellers loupe is all you need, plus some solder braid and flux to tidy up any bridges. Then IPA to clean up.

 

Last Edited: Fri. Jul 31, 2020 - 11:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If the chip has a pad, then it maybe a QFN package. These can be a right be-ach. I use a multimeter to check each pin for the substrate diode. Assuming the 0V is connected to the chip, use the meter’s diode function to measure between 0v and each of the pins. A short is a short, an open is an open and a good connection should measure as a diode. Make sure there is nothing else connected to the pin. I use a hot air tool to reflow QFNs and frequently need to touch up with a fine point soldering iron. The number of times i could swear the solder joint looked good but was open circuit.

Don’t feel bad if you made a mistake - my list is longer than a bog roll! I figure i’ve done well if i get better than 80% correct on the first spin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

and I do all my SMT assembly on the kitchen stove

Watts for dinner?

     ...a two layer sandwich with a side of fried chips.  Dip is available upon request. 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My first thought on reading that you had ISP problems was to investigate your ISP header .... Well WTF, it's missing. You completely omitted that from your design. All you needed to do was replicate the 6-pin ISP header from the Arduino, it's right there on the schematic you linked to.

 

No wonder you're having trouble.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The 3x2 ICSP header isn't mandatory but it makes life a lot easier when hardware programmers have the matching connector. But that does assume all the required signals are available *somewhere*, e.g. /RESET.

 

This may not be so obvious when using an Arduino as ISP. Spend a couple of $/£/€ on a USBasp from eBay, or buy a Snap or PICKit if you need debugging capabilities.

 

Depending on the board layout, it may be possible to find the /RESET trace, scratch off the solder mask, and solder on a flying lead. But looking at the schematic, maybe there is no /RESET trace.

Last Edited: Sat. Aug 1, 2020 - 12:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Gosh golly, thank you all so much for the warm welcome and the genuinely unbelievable level of support!

 

Based on all the feedback it seems like I should attach the complete schematic, which I have done in the opening post.

 

Brian Fairchild:

  • MISO, MOSI, & SCK are just brought out to a standard 2x3 ICSP header

 

avrcandies:

  • The reflow station I was using plays pretty fast and loose with its temperature readout. What temperature would you recommend?
  • I understand the schematic conventions but downward ground won't fit in certain areas
  • I am using an external 16MHz oscillator (Y1)
  • I am unsure what you mean by "AVR programmer" so I'm going to assume that no, I don't have one 😅

 

DocJC:

  • I realise now I've never had to set the fuses on something before. I was planning to use the Arduino ISP program to setup the atmega chip. Is that possible, or do I need to extra steps? (Right now, this is just going to be an Arduino Uno clone)
  • Yes, DAP (P33) is the thermal pad

 

Simonetta:

  • I have now attached the full schematic to help clarify this. Yes, there's an external pullup resistor
  • Good tip on the sewing needles, I'll have to try that
  • But in response to "lol, use an arduino" I'm specifically doing this to learn about PCBs so that I'm better equipped to both work with, and design these chips in the future.

 

ron_sutherland:

  • Thanks for the really pertinent and useful personal insight. I have just traced my trace, and my track is not routed through the op-amp but I will need to power it on to confirm that SCK isn't being clamped
  • Agreed, my uno has a few more pins and a few other features which will hopefully make the eventual release of this worthwhile!

 

obdevel:

  • I have now attached the full schematic to the opening post
  • Our first batch was on the stove too! We added sand to help the temperature be more even but after using a reflow station we were literally sold. like 50USD and so much flexibility.
  • Do you have any links where I could see your work, especially with the CP2102? It's the first time I've ever used it and I'm not turning up too many good sources of information on personal experiences with them.
  • We went the full stencil and paste route but have been dismayed at the quantity of solder bridges. Maybe 1/10 of our pins are bridged. Is that just how it is when working at home, or maybe the size of these components, or is it just that we happened to buy lead-free paste?

 

Kartman:

  • Despite the username, your words really helped. So disheartening after weeks of research, designing, etc. things just fall apart on just putting the bloody thing together!
  • I am using a QFN. I've not done too much work with microcontrollers before. Do you do this test pre-or-post assembly?
  • Should every single pin register as a diode, even the power inputs/outputs?
  • Do you have any links on videos, blogs, whatever on this process? There's a lot of "information" out there, but frequently it's either flat-out wrong or irrelevant to what I'm doing right now.

 

N. Winterbottom:

  • The ICSP header is present and populated. I thought it didn't do anything besides present an easily accessed, standardised connection point?

 

Brian Fairchild:

  • MISO, MOSI, & SCK are just brought out to a standard 2x3 ICSP header

 

 

Again, thanks for all of the feedback and help!

 

So nice to have people who have some experience with this stuff!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pine wrote:

  • MISO, MOSI, & SCK are just brought out to a standard 2x3 ICSP header

The signals & pin numbers are correct but the pin locations look oddly placed (on the schematic, that is). Did you do the PCB layout as standard ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman:

  • Despite the username, your words really helped. So disheartening after weeks of research, designing, etc. things just fall apart on just putting the bloody thing together!
  • I am using a QFN. I've not done too much work with microcontrollers before. Do you do this test pre-or-post assembly?
  • Should every single pin register as a diode, even the power inputs/outputs?
  • Do you have any links on videos, blogs, whatever on this process? There's a lot of "information" out there, but frequently it's either flat-out wrong or irrelevant to what I'm doing right now.

I fear you are confusing me with Eric Cartman :) When dealing with tricky technical problems I am frequently heard to mutter obscenities though.

 

There's not much use testing the chip before you solder it!!!  I usually solder the QFNs first to the board then test the pins.

 

Not every pin will look like a diode - this varies on chip type. After you've tested a few chips this way, you'll get to know what to expect for a given chip/pin. If most of the pins are testable this way, you've narrowed the possibilities for solder joint failures somewhat. 

 

Videos/blogs? Not from me. I figured this process out myself - although the concept goes back to the dawn of electricity. As for hand soldering parts - everyone has their own take of the technique. I flux and put a very small solder blob on each of the ic's pads and the same on the pcb. Squirt a bit of flux gel around the pads, locate the ic and wave the hot air tool around. Use a long thin object to push the chip into place. If you have solder paste and a stencil - only stencil the part you want to place, position the chip and wave the hot air tool around until you see the solder melt. As for temperature, the solder should melt in 10-15 seconds in most cases. You'll soon find out if you use too much temperature as the board will start to bubble. The right amount of temperature to get the solder to melt in the right time. Some experimentation required.

 

As for testing the board - divide and conquer. Get the bits that are easy to test going first - I'd get the usb working - you can do a loop back on tx & rx to see that it is working. 

As for the micro - see if you can read the flash/id bytes first up. Assuming you haven't touched the fuses, then no external crystal is required. Assuming that works, then write some code to toggle ports pins/flash a led - whatever is simple and will give a simple indication that it is working. Once you've confirmed this, then burn the fuses to select the external crystal/resonator.

It should be downhill from there.

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You do have the Tx output from the AVR hooked to the RX input of your usb chip, correct?

You do have the Rx input to the AVR hooked to the Tx output from your usb chip, correct?  (always verify the direction "names" on your chips, in the rare case they try to "help" you by swapping them).

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Mon. Aug 3, 2020 - 10:55 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pine wrote:

obdevel:

  • I have now attached the full schematic to the opening post
  • Our first batch was on the stove too! We added sand to help the temperature be more even but after using a reflow station we were literally sold. like 50USD and so much flexibility.
  • Do you have any links where I could see your work, especially with the CP2102? It's the first time I've ever used it and I'm not turning up too many good sources of information on personal experiences with them.
  • We went the full stencil and paste route but have been dismayed at the quantity of solder bridges. Maybe 1/10 of our pins are bridged. Is that just how it is when working at home, or maybe the size of these components, or is it just that we happened to buy lead-free paste?

 

Here are a couple of recent boards with CP2102. I don't use stencils for the low volumes that I make; too messy to offset any time saving. I dilute some solder paste with IPA and dot the pads with a toothpick, then place the parts with tweezers. I don't go smaller than 0805, SOT23, etc. I'm reasonably practised with my workflow now and don't have any problems with QFN or USB connectors. If do get a solder bridge on a QFN part, I just add some flux and wipe the iron around the edge of the part.

 

I play faster and looser with the circuit design; no ferrites, no transient suppression, no series resistors on D+/D- or TX/RX, etc. Just a diode to prevent backfeeding the USB port from any external supply.

 

If I needed larger volumes, I'd probably consider having the PCB assembly done in China as well.

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

obdevel wrote:
I dilute some solder paste with IPA and dot the pads with a toothpick, then place the parts with tweezers. I don't go smaller than 0805, SOT23, etc.

I find I can place all of those parts using tweezers and a soldering iron, no need to mess with paste, then flux and reflow using a hot air gun.  Your two examples above would be easy to do!

 

Jim

PS: nice job on both of those examples.

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

obdevel wrote:
I dilute some solder paste with IPA and dot the pads with a toothpick, then place the parts with tweezers. I don't go smaller than 0805, SOT23, etc.

I find I can place all of those parts using tweezers and a soldering iron, no need to mess with paste, then flux and reflow using a hot air gun.  Your two examples above would be easy to do!

 

Jim

PS: nice job on both of those examples.

 

Thank you Jim. I appreciate the compliment.

 

I'm so practised I actually find my way quicker, although I can do rework with an iron if necessary. And anything with a hidden external pad really needs to be reflowed. On the second board, the QFN part was replaced using a hot air gun after I let the smoke out.

 

I have one double-sided design where I hand solder the less busy side and that goes down to 0603, but it's never a 'pretty' as the reflowed side. I should experiment with different solder temps.

 

I design some boards for people who can't/won't/don't do surface mount and going back to through hole assembly is tiresome :)

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Perhaps a brief off-topic interlude is acceptable...

 

Nice job on the boards!

 

Did you 3D print the blue case yourself?

 

JC