SAM21D Compare match interrupt

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.

Thanks in advance

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.

My understanding is that the third parameter is the period in µ-seconds, so 5e5 is 500,000 µs so half a second ==> 2 Hz frequency for calling myISR()

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.