Hi. There is some problem with SoftwareSerial on SAMD21 chip (Seeeduino XIAO board). After using attachInterruptWakeup (ArduinoLowPower library) SoftwareSerial do not receive data correctly (transmit works). I think it is related to reconfiguration of CGLK. Here is configuration that library performs:
static void configGCLK6()
{
// enable EIC clock
GCLK->CLKCTRL.bit.CLKEN = 0; //disable GCLK module
while (GCLK->STATUS.bit.SYNCBUSY);
GCLK->CLKCTRL.reg = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK6 | GCLK_CLKCTRL_ID( GCM_EIC )) ; //EIC clock switched on GCLK6
while (GCLK->STATUS.bit.SYNCBUSY);
GCLK->GENCTRL.reg = (GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC_OSCULP32K | GCLK_GENCTRL_ID(6)); //source for GCLK6 is OSCULP32K
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY);
GCLK->GENCTRL.bit.RUNSTDBY = 1; //GCLK6 run standby
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY);
/* Errata: Make sure that the Flash does not power all the way down
* when in sleep mode. */
NVMCTRL->CTRLB.bit.SLEEPPRM = NVMCTRL_CTRLB_SLEEPPRM_DISABLED_Val;
}
Can anyone help with figuring out reason of such behaviour and solution of this problem?
I know that the simplest way is to use hardware UART but I want to know at least how to reconfigure GCLK (if it is the reason) by default to solve the problem with SoftwareSerial.
Thanks.