Fail to receive data from SARA N211 after issuing systemSleep()

Hi
I’m having some trouble with the SARA N211 and systemSleep(). If setting the board into sleep, I cannot receive any data from the modem, but sending works.
If I use delay(8000) instead of systemSleep, everything work ok.
Am I missing something here? Do I have to activate the RX pin somehow after waking up from sleep? As I said, sending data to modem works fine.

Code:

[CODE]#include <Sodaq_wdt.h>
#include <Sodaq_LSM303AGR.h>

Sodaq_LSM303AGR accelerometer;

void setup() {

// Bootup delay to programm the board.
delay(5000);

Wire.begin();// I2C for the accelerometer

// Disable the LSM303AGR
accelerometer.disableAccelerometer();
accelerometer.disableMagnetometer();

pinMode(LED_BUILTIN, OUTPUT);
pinMode(MAG_INT, OUTPUT);
pinMode(GPS_ENABLE, OUTPUT);
pinMode(SARA_ENABLE, OUTPUT);

digitalWrite(LED_BUILTIN, LOW); // led low=off, high=on
digitalWrite(MAG_INT, LOW); // we need to make this low otherwise this pin on the LSM303AGR starts leaking current
digitalWrite(GPS_ENABLE, LOW); // low=poweredoff, high=poweredon
digitalWrite(SARA_ENABLE, HIGH); // low=poweredoff, high=poweredon

Serial1.begin(9600);
pinMode(SARA_TX_ENABLE, OUTPUT);
digitalWrite(SARA_TX_ENABLE, HIGH);

//this code is needed to setup watchdogtimer and to make MCU sleep
sodaq_wdt_enable(WDT_PERIOD_8X); // watchdog expires in ~8 seconds
sodaq_wdt_reset(); // restting the watchdog

initSleep();

SerialUSB.flush();
SerialUSB.end();
USBDevice.detach();
USB->DEVICE.CTRLA.reg &= ~USB_CTRLA_ENABLE; // Disable USB
}

void loop() {
sodaq_wdt_reset(); // restting the watchdog
String atResponce;
Serial1.println(“AT”);
if (Serial1.available() > 2) //Should receive AT\r\nOK\r\n
{
while (Serial1.available())
{
atResponce.concat((char)Serial1.read());

}
  digitalWrite(LED_BUILTIN, HIGH);
  sodaq_wdt_safe_delay(100);
  digitalWrite(LED_BUILTIN, LOW);

}
//delay(8000);
systemSleep();
}

/**
Initializes the CPU sleep mode.
*/
void initSleep()
{
// Set the sleep mode
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
}

/**
Powers down all devices and puts the system to deep sleep.
*/
void systemSleep()
{

__WFI(); // SAMD sleep

}[/CODE]

Hi Kristofer,

By default the UART clock will be disabled when the board enters deep sleep mode. As such you will not be able to receive data over the UART while the board is asleep, and the board will not wake when data arrives.

It is possible to configure the UART to run while in sleep mode. This is not trivial though and it requires that you configure the oscillators and the clock providers, which generate the UART’s clock, so that they continue to run in standby (sleep)… The frequency of the source clock has a major impact on the power consumption (in sleep). Additionally, there is a minimum clock required for any given baudrate.