SAMD21 wake up time from deep sleep

Hi MartinL,

Thank you for the feedback. I checked my watchdog.reset() method and I think I am using the non-blocking technique:

void WITAP_Watchdog::reset() {
  if (!WDT->STATUS.bit.SYNCBUSY) {               // Check if the WDT registers are synchronized
    REG_WDT_CLEAR = WDT_CLEAR_CLEAR_KEY;        // Clear the watchdog timer
  }
}

However, your suggestion gave me an idea and I looked further into the RTCZero library. When it reads the RTC there is a blocking sync:

/* Synchronise the CLOCK register for reading*/
inline void RTCZero::RTCreadRequest() {
  if (_configured) {
    RTC->MODE2.READREQ.reg = RTC_READREQ_RREQ;
    while (RTCisSyncing())
      ;
  }
}

Since the RTC is clocked using the 1.024kHz clock, the sync delay will be similar I think. There are many places in the RTCZero library that use the blocking sync.

As I dug through the RTCZero library and the datasheet it appears the RTC hardware on the SAMD21 has a major shortcoming. There doesn't appear to be any way to read the RTC clock directly without the 6ms sync delay when you wake from sleep. Moreover, you cannot adjust the alarm without hitting this roadblock as well.

I can probably design around this issue by using my own clock register but I pretty much loose most of the functionality of the RTCZero library because I will need to re-write many of the functions it provides. Are you aware of anyone that may have already addressed this issue?