ISP works with Atmega328P, but not Atmega328PB

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

I have a new hardware design that was intended for the Atmega328PB, but the ISP programmer (#3172 Pololu USB AVR Programmer v2.1) indicates that it can't connect with the MCU as follows:

 

avrdude.exe: stk500v2_command(): command failed
avrdude.exe: initialization failed, rc=-1

 

The odd thing is that if I remove the Atmega328PB MCU and populate a Atmega328P MCU on my new hardware that I pulled off an Arduino Nano board, it programs just fine! I am making sure to change the -p parameter in the command line. Also, worth noting is that I have #3160 Pololu A-Star 328PB. My ISP programmer can program it just fine. It's the combination of the Atmega328PB and my new hardware that seem to cause a conflict.

 

Another clue: When an Atmega328PB MCU is on my hardware and I connect the ISP programmer to it, my virtual COM port disappears about 70% of the time I connect. Possible power surge..? But, why wouldn't it happen with the Atmega328P?

 

I've reviewed the differences between the Atmega328P and Atmega328PB, but I can't seem to find anything that would account for this behavior. I'm pulling my hair out. Please help!

This topic has a solution.
Last Edited: Tue. Sep 7, 2021 - 02:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome!

ignisuti wrote:
I've reviewed the differences between the Atmega328P and Atmega328PB, but I can't seem to find anything that would account for this behavior.
One less power pair; power should be stable with reasonable noise.

AVR ICSP signals could have excessive loading.

 

Additional Pin Functionalities | AT15007: Differences between ATmega328/P and ATmega328PB

Shared Use of SPI Programming Lines | AVR® Microcontroller Hardware Design Considerations

 


Pololu - A-Star 328PB Micro - 5V, 20MHz

Pololu A-Star 328PB Micro schematic

Pololu USB AVR Programmer v2.1

 

"Dare to be naïve." - Buckminster Fuller

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

gchapman wrote:

One less power pair; power should be stable with reasonable noise.

 

the PB has a port pin where the P does not, you must change your layout for the PB, otherwise the port pin will short out the power rail. 
 

jim

 

FF = PI > S.E.T

 

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

Thank you both for your replies!

 

Are you referring to pin 6 (was VCC, but is now PE1)? That fits my symptoms very well. However, I just checked and my hardware layout shows this is not routed anywhere. I double-checked with a meter and can confirm it is NOT tied to power or ground.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you set for the right device signature?

Did you set the right programming speed? The chip from the nano will have set fuses and will run at a higher speed probably than the virgin chip. programming speed needs to be at or below 125KHz for a virgin chip.

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

Digital Supply | AVR® Microcontroller Hardware Design Considerations

...

This may give the impression that the power supply is not critical but, as with any digital circuit, the supply current is an average value. 

...

"Dare to be naïve." - Buckminster Fuller

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

meslomp wrote:

Did you set for the right device signature?

Did you set the right programming speed? The chip from the nano will have set fuses and will run at a higher speed probably than the virgin chip. programming speed needs to be at or below 125KHz for a virgin chip.

 

I believe I'm using the correct signature with this command "-p atmega328pb". I believe confirmation of this occurs when my #3160 Pololu A-Star 328PB programs without complaining.

 

I really like the idea of checking the programming speed. That issue would explain everything I am seeing (only the virgin chips not programming). Can you please give me a bit further guidance on how to check this as I have never programmed an Arduino using the command line or ISP before. Where can I change the speed?

 

More details...
Without using the command line, here are my Arduino settings:

Board: Pololu A-Star 328PB
Version: 5V, 16MHz
Port: COM11
Programmer: STK500 for Pololu A-Star 328PB

Then, to program, I go to Sketch > Upload Using Programmer

 

When I use the command line, I run this command:

"C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude.exe" -C "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -C +C:\Users\<...>\AppData\Local\Arduino15\packages\pololu-a-star\hardware\avr\4.0.2/extra_avrdude.conf -v -p atmega328pb -c stk500 -P COM11 -B 0.5 -U flash:w:"C:\<...>\image.hex":i

 

 

gchapman wrote:

This may give the impression that the power supply is not critical but, as with any digital circuit, the supply current is an average value. 

I am mainly attempting to power via the Pololu ISP programmer via enabling the 5V output. However, I've tried powering it many different ways. I do not believe this is my issue because I can program the Atmega328P chip just fine.

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

ignisuti wrote:
-B 0.5

too fast for a 1MHz system clock, try -B 8 until you change clock fuses for a faster clock....

 

Jim

edit: or some value between (4 - 8)

 

FF = PI > S.E.T

 

Last Edited: Tue. Sep 7, 2021 - 01:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

ki0bk wrote:

ignisuti wrote:
-B 0.5

too fast for a 1MHz system clock, try -B 8 until you change clock fuses for a faster clock....

 

Jim

edit: or some value between (4 - 8)

 

That did the trick!!!

Thank you everyone, especially Meslamp and kiobk.

I tried -B 8 and it worked! I'll experiment with other speeds. If anyone has suggestion for fastest speed, please post.

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

ignisuti wrote:
I am mainly attempting to power via the Pololu ISP programmer via enabling the 5V output.
USB VBUS is noisy with a potential for instabilities; alternatively, power from a battery or an unconditionally stable power supply (resistor to current limit into a Zener diode; conversely, shunt regulators are easy to make stable)

 

Pololu - New product: Pololu USB AVR Programmer v2.1

[1/4 page]

So in the end, we decided to redo our PCB and put in a dedicated high-side power switch with a controlled slew rate. The new programmer can now power target boards with up to about 33 µF on their logic supplies.

NJM17431 Adjustable Precision Shunt Regulator - NJR (New Japan Radio) | Mouser (datasheet, page 7, high SOA)

Voltage Reference Bests Zener Diode as Low-Current Bias Source | Electronic Design

LM4040 | Microchip Technology

[datasheet, page 19, top of left column]

4.0 APPLICATION INFORMATION

The stable operation of the LM4040 and LM4041 references require an external capacitor greater than 10 nF connected between the (+) and (–) pins. Bypass capacitors with values between 100 pF and 10 nF have been found to cause the devices to exhibit instabilities.

 

"Dare to be naïve." - Buckminster Fuller

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

For the programming speed, you need to keep in mind that the modern processors have a "clkdiv8" fuse bit which effectively divides the selected clock source by 8.

Default (modern) chip run on a 8MHz RC oscillator ( check the datasheet if you are going to use a different processor) So with the fuse set it only runs at 1MHz....

Programming has a maximum allowed clock speed of 1/4th of the CPU clock speed. So for a virgin chip that would be 250KHz. But as the RC oscillator has a very high frequency tolerance you want to be at least 1 step below that.

Used to the AVR-ISP MKII that has 125KHz as lower step I suggested going to that speed and it should always work.

 

Once you have set the fuses to what you actually want clock speed wise you can also again increase the programming speed for faster programming.

 

I typically always use 125KHz for programming except when doing the very large memory chips. This to avoid issues with first programming a new board and then spending at least an hour to find out that there not is a board problem, but I accidentally still have a way to high programming speed.