I am using the RTC in a SAML21 to keep track of time. It is using the OSCULP32K 1 kHz output as the driving clock for the RTC. I also have TC4 set up as a 16-bit counter also using the OSCULP32K clock, routed through GCLK3. The desire is to reset/restart TC4 each second so I can have sub-second timestamps.
I initially set up the RTC as an event generator, using the 7th periodic event. TC4 consumes the event and restarts. The frequency of the TC4 reset was 1Hz as desired, but the resets did not line up with the RTC counts. When looking at the values TC4 resets about halfway through the RTC seconds. The same thing happens if I clear the TC4 count value from an interrupt using the 7th periodic event.
This seems strange since the 7th periodic event/interrupt is generated by the 10th bit of the RTC pre-scaler, dividing the RTC input by 10.... which is the same way the seconds are counted in the RTC??
Am I wrong to presume that the 7th periodic interrupt should happen at the top of each RTC second and not somewhere in the middle of the second?
Any advice on this would be appreciated.