UNO with ATMEGA328PB running at Half Speed vs ATMEGA328P

Hello All!

Given the worldwide shortage of 328p chips, I am attempting to move to the 328pb chip and have 1000's of them on order.

Today I got a sample of the PB chip in and promptly installed it on my Arduino UNO to test it. Before swapping the 328p chip for the 328pb chip, I ran a speed test uring the following code:

bool COUNTLOOPS = true; // loops per second code
long lastMillis = 0;    // loops per second code
long loops = 0;         // loops per second code
long tempThousands = 0; // loops per second code
long tempMillions = 0;  // loops per second code

void setup() {
  Serial.begin(9600);
}

void loop()  {
  loopsPerSecond();

}

void loopsPerSecond() {
  if (COUNTLOOPS == true) {
    long currentMillis = millis();
    loops++;
    
    if(currentMillis - lastMillis > 1000){
      Serial.print("Loops Last Second: ");    
      Serial.println(loops);
      lastMillis = currentMillis;
      loops = 0;
    }
  }
}

The serial monitor reported 270,000 loops per second.

I installed the 328pb chip, and installed the new boot loader using the following settings and to my surprise the serial monitor returned a value of 130,000 loops per second with no other changes.

Any idea what it could be? For sure it's a 16MHz crystal in the UNO. To prove that to myself I ran the following code which should output an 8MHz square wave and it did.

#include <avr/io.h>

int main(void) 
{
    // Do PWM on pin D5, reaching 8Mhz

    DDRD = (1<<5); 
    TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM01) | _BV(WGM00);
    TCCR0B = _BV(WGM02) | _BV(CS00);
    OCR0A = 1;
    OCR0B = 0;
    while (1);
}

Any ideas why this is running the LPS code at half rate?

Thanks so much for any help!

Found a solution!

I went to avrdude.conf and on line 8592 I changed the signature of the 328p device from:

signature		= 0x1e 0x95 0x0F;

to

signature		= 0x1e 0x95 0x16;

Then I selected the default UNO board in the Arduino IDE and uploaded code and it runs fast as ever! I'm not sure why this is, but it's working now!

Is that a typo ? The signature change is to the same value ??

Yeah, but pretty sure that external would be the correct selection.

the value went from ending in 0x0F to ending in 0x16

Sorry see that now - using iPhone and it was off the screen

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.