Am I bricking my AtMega328PB chips?

Hi,

I am using an AtMega328PB in my project with a SIM808. I can upload my code to it via a USBtiny device with the ISP header. After a few sketches, it won't accept any more. It just says initialization error, rc=-1. Then I replace the chip and start uploading sketches again, and after a few sketches, it does it again. I also can't burn the bootloader after it does this. Any ideas as to what is happening here? I only have a few of these left, so I don't want to ruin them all...

Thanks,
Joe

What behavior do you see trying to program it with a USBAsp? Asking because I am unsure of what problem causes that error on the USBTinyISP

DrAzzy:
What behavior do you see trying to program it with a USBAsp? Asking because I am unsure of what problem causes that error on the USBTinyISP

I get this error message

Arduino: 1.8.11 (Windows 10), Board: "ATmega328, Yes (UART1 328PB only), 328PB, BOD  disabled, LTO disabled, 16 MHz external"

Sketch uses 1282 bytes (3%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'
avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I am using a SparkFun AVR Pocket Programmer.

Ah, you don't happen to have a USBAsp on hand? (I meant with a USBAsp connected to it - otherwise you get the error you got, because there isn't any USBAsp to talk to)

I, unfortunately, do not. I only have the AVR Pocket Programmer. I should also note that I tried to program it with an Arduino Uno coded with the ArduinoISP program and used the Arduino as ISP programmer and it brings up the same dialogue. I have no clue what is going on...lol

Are you getting the expected voltage on Vcc? (wondering if the SIM808 is trying to do something that causes power supply to drop out)

Is anything connected to the SPI pins or Reset? If yes on SPI, make sure that the CS line(s) for whatever device that is are held high by a physical pullup to ensure that they remain high while you program '328pb.

DrAzzy:
Are you getting the expected voltage on Vcc? (wondering if the SIM808 is trying to do something that causes power supply to drop out)

Is anything connected to the SPI pins or Reset? If yes on SPI, make sure that the CS line(s) for whatever device that is are held high by a physical pullup to ensure that they remain high while you program '328pb.

I am using a 3.7v LiPoly battery to power the whole project, which is about 4.2v fully charged. The reset pin is always pulled high with a 1kΩ resistor. I have also removed the battery and soldered tiny wires onto the AtMega itself and fed it 5v and still, the same result ensued. The SIM808 isn't the issue I don't believe. It has its own switch to power the 808 itself.

Josephm3502:
I only have the AVR Pocket Programmer.

When using the AVR Pocket Programmer, you need to select Tools > Programmer > USBtinyISP, not Tools > Programmer > USBasp.

Josephm3502:
I tried to program it with an Arduino Uno coded with the ArduinoISP program and used the Arduino as ISP programmer and it brings up the same dialogue.

If you have the correct programmer selected from the Tools > Programmer menu, that definitely shouldn't happen. However, If you selected Tools > Programmer > ArduinoISP or ArduinoISP.org, you will get a similar error. You need to select Tools > Programmer > Arduino as ISP when you are using an Arduino as ISP programmer. I know it's confusing that the sketch for the Arduino as ISP programmer is named ArduinoISP, but the ArduinoISP programmer is completely different from the Arduino as ISP.

The reset pin is always pulled high with a 1kΩ resistor.

That is a pretty strong pullup resistor. The usual is a 10K.

pert:
When using the AVR Pocket Programmer, you need to select Tools > Programmer > USBtinyISP, not Tools > Programmer > USBasp.
If you have the correct programmer selected from the Tools > Programmer menu, that definitely shouldn't happen. However, If you selected Tools > Programmer > ArduinoISP or ArduinoISP.org, you will get a similar error. You need to select Tools > Programmer > Arduino as ISP when you are using an Arduino as ISP programmer. I know it's confusing that the sketch for the Arduino as ISP programmer is named ArduinoISP, but the ArduinoISP programmer is completely different from the Arduino as ISP.

When uploading with a AVR pocket, I use the USBtinyISP. When programming with the uno, I use Arduino as ISP. It gives me the same error message every time. Could it be the fact that I have both UART ports tied to the same ISP header?

justone:
That is a pretty strong pullup resistor. The usual is a 10K.

Ok. I will solder in a 10k. That is the resistor that I used before, but saw several standalone circuit diagrams using a 1k. I guess a 10k would make more sense, though. The programmer wouln't have to supply so much current to the reset pin to get it to change states...

IIRC many of the programmers have resistors in series with the I/O lines - so it's plausible that that's the problem!!

DrAzzy:
IIRC many of the programmers have resistors in series with the I/O lines - so it's plausible that that's the problem!!

I will cut the traces to UART 1 tomorrow and just solder tiny wires from the ISP port to UART 0 and see if that midigates my problem. When bootloading these chips, they only seem to accept bootloading on UART 0. I will try this tomorrow and report back with the results. I just find it weird that they accept a few uploads and then quit...

Josephm3502:
When uploading with a AVR pocket, I use the USBtinyISP. When programming with the uno, I use Arduino as ISP. It gives me the same error message every time.

Are you saying you always get this exact error message?:

avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'
avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'

pert:
Are you saying you always get this exact error message?:

avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'

avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'

No. I only tried the USBasp because it was recommended that I try it. I don't believe it has anything to do with the programmer because I can use it to upload to an arduino uno or nano just fine. I think it may be the wiring of my project itself that is causing this. My original error message is in my first post on this thread...