Is there a good way to artificially add time to the millis() value? What I’ve tried so far hasn’t worked.
I have a project that uses millis() for timing, but also disables interrupts often enough that millis() loses significant time. I’m trying to find a way to mitigate that by adding time back to millis() based upon micros(), but I havent had much luck. I’m not looking for 100% millis accuracy, but closer than “not close at all” would be cool.
It looks like I can call System1MsTick
directly, but I’m not having much luck there. Here is my test code:
void setup(){
delay(10000); // Give myself time to get serial connection started
uint32_t startMillis = millis();
delay(10);
Serial.println(String(millis()) + " " + String(millis()-startMillis));
for(int i = 0; i < 1000; ++i) {
System1MsTick();
}
Serial.println(String(millis()) + " " + String(millis()-startMillis));
}
Hammering System1MsTick
seems to have no effect at all. Is there a better way to do this?