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!