Sparkfun edge: Accuracy of using millis()

Hi,

I am using Arduino package to flash code in my Sparkfun edge. I use millis() function to check for delay and time period. When I ran it for 10 mins, I got an error of around 2 seconds. Can you please let me know the accuracy of the clock used in Sparkfun edge ( apollo 3 blue). Is there any way to increase accuracy??

I don’t know the accuracy off the top of my head, but I can tell you this:

The timing functions are supported by the stimer module and currently it is configured to run off the High Frequency RC (HFRC) clock at 3 MHz.

You can check the Apollo3 blue datasheet for more information about the accuracy (probably)

https://cdn.sparkfun.com/assets/d/a/7/c … v0_9_1.pdf

millis() will not increment when the the micro is in an ISR. If you are using hardware interrupts, and your ISR takes longer than one millisecond to complete, that could be the source of your timing irregularity.

Below is the sample code which I run in Sparkfun edge and I compare the difference with the timestamp in Serial monitor. If we observe for more than 10 minutes, these two are some seconds apart. I am working on to reduce this difference.

unsigned long t1;

void setup() {
  
	Serial.begin(9600);
	t1 = millis();
	Serial.println(millis());
}

void loop() {
    
  if((millis() - t1)>=60000)
  {
	Serial.println(millis());
	t1 = millis();
  }
  
}

Can you please let me know if there is any way of syncing time with real time apart from using GPS module and RTC??