Millis/delay different behaviour in regular uno vs Pololu Atmega328PB/Minicore

Hello,

thanks for your help upfront

I am seeing a strange behaviour when using millis on ATmega328PB/MiniCore. I used the following program to test

void setup() {
  Serial.begin(115200);
}
void loop() {
  static uint32_t lastPrint;
  uint32_t topLoop = millis();
  if (topLoop - lastPrint >= 2000) {
    lastPrint = topLoop;
    Serial.println(topLoop);
  }
}

but the problem is same in other implemntations or by using delay

Output based on Pololu A*Start 238PB using MiniCore
2000
2000
4000
6000
8000
2000
2000
4000
6000
8000

Same program on regular Uno with Minicore shows completely normal behaviour.

Thanks a lot
Gerhard

Note that this line does not initialize lastPrint. It would be wise to initialize it to zero, because it will otherwise start with an unpredictable value.

static uint32_t lastPrint;

The ATmega328PB is new and significantly different than the ATmega328P on the Uno, although it is supposed to be backward compatible.

Perhaps Minicore does not fully support the former. Try it with Pololu's libraries instead.
Also, post on the Pololu forum. The engineers there are very responsible and will take notice. But first, fix the initialization.

Looks like it might be resetting, say, due to an 8s watchdog timeout.
Try putting a print in setup() to show that the board is restarting.

2 Likes

I suppose it could also be a brown out if the power supply is overloaded or otherwise performing poorly. It seems the Pololu A-Star 328PB (5 volt version) has a threshold of 4.3v. (If you have not replaced the bootloader which may also have changed the fuses). The Uno is more tolerant with a threshold of 2.7v.

Thanks for your support, meanwhile I confirmed the board is resets in a periodically. I use also Pololu AVR 2.1 programmer which has the option to supply the board and this option is used.

Today evening I will try with an independent stronger power supply.

Thanks again

Hi thanks all,

it is indeed a power supply issue as during my experiments I had a sensor connected that consumes obviously to much power for the Pololu Programmer.

So my mistake, sotty to bother you

Static variables are initialized to zero by default.

1 Like

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