We've got a real head-scratcher with the SAML21 RTC peripheral at the moment.
It is only present on some of our boards - which leads us to think there may be a hardware influence
All we are doing is:
Set the SWRST bit in the CTRLA register to reset the peripheral
Wait until the SWRST bit clears in the SYNCBUSY register - this stalls on the "bad" boards
RTC is using the external 32kHz crystal oscillator - which we know is good because we are using the same clock for a timer and also the DFLL - we are getting the expected 48MHz
Clock configuration is:
/* Turn on the digital interface clock */
system_apb_clock_set_mask(SYSTEM_CLOCK_APB_APBA, MCLK_APBAMASK_RTC);
/* Select RTC clock */
OSC32KCTRL->RTCCTRL.reg = RTC_CLOCK_SELECTION_XOSC32K;
/* Reset module to hardware defaults. */
rtc_count_reset();
... we are locking-up in "rtc_count_reset" waiting for SYNCBUSY to clear
Any clues?
~ Carl ~