I am aware that Micros/Millis functions are based on interrupts on the AVR Arduinos and consequently their accuracy can be affected by user ISRs, but my question is are the Due's Millis/Micros functions implemented similarly or not? I figure that the Due's chip is a more advanced than the AVR chips and might have dedicated hardware for this that isn't affected by ISRs, but I cannot find any confirmation. I did try to follow the implementation code through but I reached a deadend of a declaration without implementation.
I am aware that Micros/Millis functions are based on interrupts on the AVR Arduinos and consequently their accuracy can be affected by user ISRs
Accuracy should not be affected unless one of the other interrupts takes more than about 1ms to execute. Which they shouldn't!
but my question is are the Due's Millis/Micros functions implemented similarly or not?
Yep. Due millis()/etc uses the ARM "Systick" timer, which is explicitly aimed at such purposes, can typically be configured to interrupt at exactly the 1ms rate that Arduino would like while not hurting other functions (while the AVRs end up with a 1.024ms clock tick, so that the same timer can be used to drive PWMs.)
The actual ISR is in .../packages/arduino/hardware/sam/1.6.6/cores/arduino/cortex_handlers.c:
void SysTick_Handler(void) {
if (sysTickHook())
return;
tickReset();
// Increment tick count each ms
TimeTick_Increment();
}
(For some reason Due is using Atmel libsam code for TimeTick_Increment() and similar. That's off in ...packages/arduino/hardware/sam/1.6.6/system/libsam/source/timetick.c)