Skip to content

CubeCell micros() issue in Arduino code #287

@michapr

Description

@michapr

We are expecting different problems with the CubeCell using the micros() function.

To reproduce:

#include <Arduino.h>

uint32_t last = 0;

void setup() {
    Serial.begin(115200);
    delay(2000);
    while(!Serial);
}

void loop() {
    uint32_t now = micros();
    Serial.println(now);
    if(now < last) {
        Serial.println("Stopped!");
        Serial.println(now);
        Serial.println(last);
        delay(900);
    }
    last = now;
}

now should never be smaller than last, yet we get the following output about every other x seconds :

12:38:27.451 > Stopped!
12:38:27.456 > 92596866
12:38:27.458 > 92596999

Interestingly, the last value that is printed, always ends in 999 or sometimes 998 or 997.
However, removing the line Serial.println(now); makes it such that the problem doesn't happen... why?????

With millis() it runs fine - so something is wrong. Can you check it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions