RESOLVED: Problems with custom PCB (chip keeps bricking)

I'm attempting to design a small low power (3V coin cell) board that runs on SMD ATmega328p.
It works fine on breadboard with thru the hole version of the chip, but when I test actual PCB (made via iTead) I'm getting verification errors when trying to upload sketch via USBTiny ISP programmer. Sketch does seem to load tho. But when I try to burn bootloader, it bricks the chip :frowning: It completely stops responding to serial programmer...
I'm using internal oscillator (8Mhz) and power everything from 3V (power jumper on USBTiny is removed). I'm completely stuck :frowning: Destroyed 2 MCUs already...
Can anyone help me? :slight_smile:
I'm using this breadboards file.

Update:
Issue is now resolved. Chip was getting bricked because RFM69W module (an SPI device) did not have pull-up resistor. Adding this to future board revision solved the problem.

I presume you are burning the bootloader via SPI, but I've noticed you have other devices hanging off the SPI

You also have an odd thing in your design, you are using SS for both SPI devices from D10.

So both devices are will be enabled at the same time and you won't be able to communicate with either

You also have both their IRQ's on pin 2, which isnt possible either unless the devices are open collector, but I don't see a pull up resistor on D2

Did you ever build this as a prototype before you got a PCB made? did it ever work ?

As currently I can't see how it would work even if you get the bootloader installed.

If you have installed the RFM12B etc, I'd remove them both and try again to start with.

Sorry for the confusion, there's only one SPI device actually that can be soldered but pins are setup to support either rfm12b or rfm69w. Both will never be on the same board :slight_smile:

I don't see an ICSP header in your schematic.

I don't see a power bypass capacitor next to your processor or radio. See the AVR datasheet for recommended bypass capacitors.

When you burn the bootloader, are you setting the fuses correctly? If the fuses are set to expect a crystal, and there's no crystal present, the chip won't respond over SPI

DrAzzy:
When you burn the bootloader, are you setting the fuses correctly? If the fuses are set to expect a crystal, and there's no crystal present, the chip won't respond over SPI

No, as I mentioned I'm using boards definition file that takes care of that (sets clock to internal OSC).

johnwasser:
I don't see an ICSP header in your schematic.

I don't see a power bypass capacitor next to your processor or radio. See the AVR datasheet for recommended bypass capacitors.

Yeah I'm going to add ICSP in the next iteration, it's not really required since I have access to all pins anyway...
Bypass capacitors probably a good idea to have, but it works without then on breadboard...
I just soldered second board. This time only ATmega chip and headers. Programmed via ISP no problem, was even able to upload bootloader and change fuses. Add more components, everything still works. I'm now even more confused :frowning:

Bypass capacitors probably a good idea to have,

Indeed! Just these sorts of intermittent failures are exactly what to expect when you do not have bypass capacitors.

jremington:
Indeed! Just these sorts of intermittent failures are exactly what to expect when you do not have bypass capacitors.

Actually C5 is my decoupling cap for AVR chip. I placed it very close to VCC of the chip. But thinking about it gave me an idea, perhaps I bridged this or other part while soldering, gotta go probe it :slight_smile:
Oh if anyone knows, which page of ATmela datasheet has typical schematic? I searched mine and can't find it for some reason :frowning:

Need bypass cap on both VCC pins and AVCC - so three in all.
Diode across reset resistor (anode to reset) also helps keep chip from being fooled into entering high voltage programming mode from spikes on reset pin.

Typical schematic? Start with promini design.

AtmelAVR042 AVR Design Considerations.pdf (236 KB)

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05

Check that these fuse settings accomodate brown-out detection set low enough for 3V operation.

Check your battery - not all coin cells will put out enough current, or may only support brief bursts of higher current.

Thank you CrossRoads! As usual great info! I will implement additional caps and diode in my future revision of the board.
BTW on the one board that didn't get bricked, I'm having great success with low power usage. When I put it into "deep" sleep I'm getting current at around 3uA! With 3V lithium battery rated at 225mA I should get around 5 years from it (that's of course if board always sleeps, so in reality I'm hoping to get at least a year) :slight_smile:

Sorry one more question on bypass Caps.
ATmega328p in QFP package, is quite different from DIP version, specifically that both VCC pins (4 and 6) are just one pin apart, so they are very close. Does it really makes any sense to add bypass capacitor to each one?

I'd venture a guess that Atmel (and Crossroads) didn't recommend 3 bypass caps just for the hell of it :wink:

The circuitry around the voltage regulator looks messed up to me, unless I'm missing something.

I see:

Ground connected to GND of the GND of regulator - great.
10uf cap between GND and VOut - great.
1uf cap connected between VIn and GND - great.
One pin of EXT PWR connector going straight to 3.3v (hmm?)
Other pin of EXT PWR connector going into VOut of the regulator (what?!)
Nothing connected to VIn (other than one side of the cap)?

Bypass capacitors probably a good idea to have, but it works without then on breadboard.

This maybe because the bread board is full of stray capacitance, especially between the power rails. Possibly only adds up to 100pF but that might have been enough to make it function under the special conditions you had it working in.

Decoupling capacitors are not optional in electronics, you should never not have them on any circuit.

DrAzzy:
I'd venture a guess that Atmel (and Crossroads) didn't recommend 3 bypass caps just for the hell of it :wink:

The circuitry around the voltage regulator looks messed up to me, unless I'm missing something.

I see:

Ground connected to GND of the GND of regulator - great.
10uf cap between GND and VOut - great.
1uf cap connected between VIn and GND - great.
One pin of EXT PWR connector going straight to 3.3v (hmm?)
Other pin of EXT PWR connector going into VOut of the regulator (what?!)
Nothing connected to VIn (other than one side of the cap)?

Ok let me explain. Main thing I wanted to do here is isolate Voltage regulator from 3.3V line with help of a jumper. Reason is that when voltage on 3.3V line goes to around 3V MCP1703 starts to drain more power from the circuit. Problem is discussed in this forum thread.

When operating at or below the dropout voltage, an effect that is often not shown on the LDO datasheets is an increase in quiescent current. The error amplifier is doing its best to turn on the pass element harder, but to no avail once the lowest Rds is reached. The overdrive however kicks up the current consumed by the LDO itself, leading to a rise (often substantial in μA) in total current drain from the source.

I probably didn't do a good job labeling pins clearly. In my schematic, PWR (from FTDI or pin header) goes to regulator's VIn.
EXT_PWR jumper (JP1) should probably be called Vreg Bypass, because when it's opened Vout from regulator is not supplying power to the circuit, only 3V Coin cell or 3.3V header. When it's closed, Vout goes to the processor and other components. C5 bypass cap was added for this situation because when jumper is open other capacitors are disconnected. It's actually placed near ATMega chip.

P.S. I revised schematic... Among other things RFM69 footprint was removed. I found version that's footprint compatible with RFM12b, neat!

You need a 0.1uF cap from pin 20 to ground.

Thank you Mike, CrossRoads, and everyone else! I added extra parts to my board :slight_smile:

Just got new PCBs from iTead with all the recommended fixes. Still having same issue :frowning:
RFM chip is causing this somehow... I soldered everything but Radio, had no issues uploading bootloader and setting fuses. Tried both 16Mhz (board now has resonator) and 8Mhz versions, everything works.
Soldered RFM69cw chip. No problems uploading sketches via FTDI.
Tried burning 8Mhz bootloader... Bricked the processor! :frowning:
Here's error got from IDE:
avrdude: verification error, first mismatch at byte 0x0000
0xff != 0x3d
avrdude: verification error; content mismatch

After that, every time I getting:

avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

I finally resolved the issue!!! It was pullup resistor on SS line of the RFM module! I added it to the new PCB design, but didn't solder one (didn't think it was needed). Well with added 10K resistor, I'm now able to burn bootloaders without bricking chip! Someone on another forum actually suggested this solution, and he also mentioned it might be combination of USBTinyISP programmer and no pullup resistor that cause Atmel chip to get corrupted fuse values.

Yeaaaa. Glad you got it working.