PM_MODE_WAIT not working as described and how to cyclic wake up < 1sec.

Hi,

i want to make use of CPU PM_MODE_WAIT.

According library documentation:
PM_MODE_WAIT to set the CPU in wait mode (CPU is shutdown but the system clocks are running and the full regulation is maintained)

but in pm.c
case PM_MODE_WAIT:
/* Wait LP is not supported, so… just wait */
wait();
break;

In fact, the CPU continues to run. ‘wait()’ translates as ‘asm(wait;)’.
So, documentation is wrong or the function is not properly implemented.

What I am trying to archive is, that the CPU wakes up every 250ms in order to read an SPI sensor.
Only if a certain condition is met, the radio has to wake up and transmit a message.

I activated the RTC periodic task, which calls void rtc_periodic_task(void) every 252ms.
But, while in PM_MODE_STOP_2 or 3, it takes approx a second until rtc_periodic_task(void) is called.

Another attempt was using a timer, but here the ISR is not called when sleeping, since the clocks are down.

So, what’s the strategy to wake up cyclic with intervals < 1s?

Any idea is appreciated.

Mick

Hi,

I was able to help myself.
I have commented out ‘rtc_config_slow();’ in pm.c.
Now, the rtc periodic task fires with the required accuracy while CPU is sleeping.
imho, the SDK should provide a function for this.

Mick

#if (POWER_MANAGEMENT_KEEP_UPTIME == 1)
/* Enable IRCLK in stop3 mode so RTC can wake up the CPU /
ICSC1_IREFSTEN = 1;
/
The CPU is going to sleep, but before the system tick frequency is
* reconfigured to 2 seconds, to sleep longer and minimize the power
* consumption. Later, its needed to differentiate the system tick
* interrupts, from the real wakeup interrupts. This is done in the
* RTC interrupt handler.
*/
seconds_to_wakeup = sleep_seconds ? uptime + sleep_seconds : WAIT_INFINITE;
//below is causing the RTC to wake up with delay.
//rtc_config_slow();