This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Sleep until WDT timesout

Hi All,

I have up to 8 nRF52832 devices sending data back to a base unit (another nRF52832 device.)   What I'm trying to do is have the remote units wakeup at a given time,

read sensors and send message back to the base unit.  (Each remote has a unique ID that the base unit tracks the data by.)

Currently I'm using a watchdog timer to bring the device out of sleep mode (reboot and read nvram to reload system state.)

I've been trying to use:

while(1)

{

__WFE();

}

To put the device asleep, but I'm thinking the devices are waking each other up.  (I'm getting more updates than expected and battery life is lower than expected.)

Is there a better way to get the unit to stay asleep?

thanks,

Bob

Parents Reply Children
  • Hello, 

    Someone from Nordic can point you to their official examples, here's how I did it at Ruuvi:

    https://blog.ruuvi.com/ruuvi-firmware-part-11-scheduler-c95836f3105c

    That blog is a part of lot larger series and quite heavy to grasp it on its own. 

    In essence the timer interrupt adds call to data update function to Nordic scheduler, and the timer interrupt brings the tag out of the sleep. 

    First thing once tag is out of the sleep is to execute scheduled function, including data update scheduled above. 

    After scheduler has run the main loop calls yield() which in turn will call the Nordic power management function. In your case I'd add calls to switch off the mofsets in yield and switch on once the tag has exited Nordic power management. 

    You don't necessarily need to use the scheduler, just having timer interrupt is enough to bring tag out of the sleep. However I'd prefer to not run the sensor reads in timer interrupt context, as it could mask other interrupts such as SPI data ready and lock your program.

Related