CubeCell micros() function


Can anyone point me out of how to add micros() function to CubeCell please? (same as micros() function in Arduino library)

there is a ticket on github for that request open:

Just added two examples: micros and millis.

The micros function use the internal system ticker (48MHz timer), this timer of ASR6501 is not accurate, as tested, it have 1.7% error.

The delay in the example is 1000ms, ideally, the output value here should be 1000000.

But look at the printed time stamp, each print have 20 - 22ms error. It means the actual delay(1000); spend 1020 - 1022ms. Because the delay uses internal system ticker too.

So the error is (1020000 - 1002735) / 1020000 ≈ 1.7%

That’s why I didn’t use system ticker for LoRaWAN operations. Another problem is the system ticker can’t run during the deep sleep period, wake up from deep sleep will make the micros back to 0.


The millis function uses external 32.768KHz RTC clock, it a very accurate timer, and can run during the deep sleep period. As the picture has shown, it’s the same with the delay time.

But the minimum period is 1/32768 ≈ 30us, can’t be the source of micros.

Interesting. This could explain why my attempts at serial data timing with the PWM sub system needed some tweaking. My error was closer to 1.1%. Would the 1.7% you mention be fairly consistent, or would it vary from device to device? Also, what is the source of this error? Is the 48mHz derived from a PLL?

The problem is the error is not fairly consistent for each device. So can’t simply correct the error by doing the difference. We are trying to calibrate via RTC clock.

48MHz is the ASR6501’s system frequency, the reason is because of the ASR6501 chips’ hardware problem, it’s didn’t provide a very accurate system clock.

Thanks for the prompt reply.

Please tell me about how to add micros() function for cubecell. I see micros() function in micros.ino but didn’t see micros function library.