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
  • You can use an RTC to wake the system up from WFE sleep, the watchdog timeout inserts an unnecessary reset in between, which if I understood correctly is something you could avoid. Look at the example provided at nRF5_SDK_15.3.0_59ac345\examples\peripheral\rtc\main.c

  • Hi Susheel,

    My board has an external 32KHz crystal.  What is the deepest sleep mode I can put the nrf52832 into and leverage this crystal?  Goal being to wake up after a given time period (in seconds to minutes.)

    Thanks much for any pointers. I have a multi-meter on my board measuring current and I can't get it to stay below 170uA in sleep mode.  (I think I'm missing a power down mode of some sort.)

    thanks,

    Bob

  • Hi Susheel,

    I wanted to rule out that my hardware is drawing the high current, so I created a software build that just has:

    #define RAM_RETENTION_OFF       (0x00000003UL)  /**< The flag used to turn off RAM retention on nRF52. */
    
    int main( void )
    {
    #ifdef NRF51
        NRF_POWER->RAMON |= (POWER_RAMON_OFFRAM0_RAM0Off << POWER_RAMON_OFFRAM0_Pos) |
                            (POWER_RAMON_OFFRAM1_RAM1Off << POWER_RAMON_OFFRAM1_Pos);
    #endif //NRF51
    #ifdef NRF52
        NRF_POWER->RAM[0].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[1].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[2].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[3].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[4].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[5].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[6].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[7].POWER = RAM_RETENTION_OFF;
    #endif //NRF52
    
        // Set nRF5 into System OFF. Reading out value and looping after setting the register
        // to guarantee System OFF in nRF52.
        NRF_POWER->SYSTEMOFF = 0x1;
        (void) NRF_POWER->SYSTEMOFF;
        while (true);
    }
    

    The current draw in this mode is 12uA.

    So I know I'm close just missing a setting somewhere.

    thanks,

    Bob

    (ps I couldn't get the insert code feature to make the window larger above, if you click on it there is more.)

Reply
  • Hi Susheel,

    I wanted to rule out that my hardware is drawing the high current, so I created a software build that just has:

    #define RAM_RETENTION_OFF       (0x00000003UL)  /**< The flag used to turn off RAM retention on nRF52. */
    
    int main( void )
    {
    #ifdef NRF51
        NRF_POWER->RAMON |= (POWER_RAMON_OFFRAM0_RAM0Off << POWER_RAMON_OFFRAM0_Pos) |
                            (POWER_RAMON_OFFRAM1_RAM1Off << POWER_RAMON_OFFRAM1_Pos);
    #endif //NRF51
    #ifdef NRF52
        NRF_POWER->RAM[0].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[1].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[2].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[3].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[4].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[5].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[6].POWER = RAM_RETENTION_OFF;
        NRF_POWER->RAM[7].POWER = RAM_RETENTION_OFF;
    #endif //NRF52
    
        // Set nRF5 into System OFF. Reading out value and looping after setting the register
        // to guarantee System OFF in nRF52.
        NRF_POWER->SYSTEMOFF = 0x1;
        (void) NRF_POWER->SYSTEMOFF;
        while (true);
    }
    

    The current draw in this mode is 12uA.

    So I know I'm close just missing a setting somewhere.

    thanks,

    Bob

    (ps I couldn't get the insert code feature to make the window larger above, if you click on it there is more.)

Children
Related