I'm struggling to understand how the micros(), millis(), delay() and delaymicroseconds() work on the Arduino Zero.
They seem incredibly poor in accuracy/consistency and I'm struggling to understand why.
Using simple code to write out the microseconds every delay(1000) I get the following:
Zero - Delay
Time: 20876
Time: 1032178
Time: 2045180
Time: 3058174
Time: 4071176
Time: 5084177
Time: 6097178
Time: 7110179
Time: 8123174
Time: 9136176
Time: 10149177
Time: 11163174
Time: 12177178
Time: 13191176
Time: 14205179
And then using delayMicroseconds(1000000) I get:
Zero - DelayMicroseconds
Time: 33376
Time: 1046501
Time: 2061709
Time: 3076918
Time: 4092126
Time: 5107334
Time: 6122543
Time: 7137751
Time: 8152959
Time: 9168168
Time: 10183376
Time: 11199626
Time: 12215876
Time: 13232126
Time: 14248376
The Zero obviously uses the Systick Timer. So I started comparing to the Due. I get the following results using delay with the Due:
Due - delay
Time: 2014
Time: 1002013
Time: 2002013
Time: 3002013
Time: 4002013
Time: 5002013
Time: 6002013
Time: 7002013
Time: 8002013
Time: 9002013
Time: 10002013
Time: 11002013
Time: 12002013
Time: 13002013
Time: 14002013
Time: 15002013
Time: 16002013
Time: 17002013
Time: 18002013
Time: 19002013
Time: 20002013
Time: 21002013
Time: 22002013
Time: 23002013
This is far more consistent.
Does anyone have an intricate knowledge of how Systick is handled in the Arduino Zero? Or can point somewhere to read up on???
All help greatly appreciated!!
milli_due.ino (321 Bytes)