Timer Counter modules used by Arduino Zero core library

Hi,

From the Atmel SAMD21G datasheet, there are 8 Timer/Counter modules inside this MCU, 3 of which has Timer/Counter+Control function, and the remaining 5 are generic Timer/Counter module.

I would like to know which of these TC modules are being used by the Arduino Zero core library to implement those built-in functions that needs timing (e.g. millis(), delay(), etc)

Thanks!

-Ruch

Hi Ruch

I would like to know which of these TC modules are being used by the Arduino Zero core library to implement those built-in functions that needs timing (e.g. millis(), delay(), etc)

It uses none of them. The Arduino Zero uses its system ticker for millis(), delay() and micros(). This means all the timers are available and free to use as you wish.

The SAMD21G18A microcontroller on the Zero has 6 timers: TCC0, TCC1, TCC2, TC3, TC4 and TC5.

Timers TC6 and TC7 are only available on the larger, 64-pin, SAMD21J variant.

1 Like

Thanks, MartinL!

I am just curious, how does Arduino Zero actually gets the timing information from the system ticker? Can I see the code? Is this is the same SysTick used by RTOS'es?

I am just curious, how does Arduino Zero actually gets the timing information from the system ticker?

The millis(), delay() and micros() are all implemented in the "delay.c" file. This together with all the other Arduino Zero core files are located on my Windows machine at:

C:\Users\Computer\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.6\cores\arduino\

Is this is the same SysTick used by RTOS'es?

Yes, I believe the SysTick is designed to be used as an RTOS timer, although that's about as much as I know about it.

The Sys Tick (or System Timer) barely gets a mention in the SAMD21 datasheet, however information about it can be found in the ARM Cortex M0+ Generic User Guide: Documentation – Arm Developer.

Thanks, MartinL!

Very interesting. I'd like to take a look at the delay.c file and see how they implemented their delay routines.

Thanks for forwarding the link. I will take a look at it as well. :slight_smile:

-Ruch