Hello guys,
i'm very new to SAMD21 and i come from a good experience with atmega328p.
In order to translate the code done on the old atmel micro, i would like to share my issue with you and get a solution.
I need to receive an external interrupt (attached to input pin, rising edge) that in its service routine do start the timer3 in 16 bit mode. The timer shall count until it reaches the match to a value stored (in CC1 a think) and at the compare match shall interrupt its relative service routine.
In that service routine the timer counter shall load a new value in CC1 and restart counting from 0.
I don't need to handle the overflow.
Each timer tick shall be of 1us.
so for the first part, attachInterrupt(digitalPinToInterrupt(inputPin), serviceRoutine, RISING);
should get you going.
for the second part you could have a look at the (non officially released nor maintained) Adafruit_ZeroTimer library which provides simple wrappers for Timer Counter 3,4,5 on SAMD21 as a source for inspiration. See this post as well
Thank you.
I have already read that post on the timer library.
So using this code
SAMDtimer mytimer2 = SAMDtimer(4, myISR, 5e5);
i should achieve the timer 4 calls myISR periodically at 500KHz frequency.
The link to the documentation relative to this library does not exist anymore.