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

register retention mode and wakeup

now I'm on going NRF24LE1 project to low power mode. I try to find several reference as link below, but both of them can't open, someone can help me ?

https://www.nordicsemi.com/eng/Nordic-FAQ/All/How-to-setup-register-retention-mode-on-the-nRF24LE1 

https://www.nordicsemi.com/eng/Nordic-FAQ/All/How-to-setup-register-retention-mode-timer-on-on-the-nRF24LE1 

Parents
  • Which power down mode should I use with the nRF24LE1?

    The nRF24LE1 supports 4 different power down modes

    • Deep sleep
    • Memory retention timers off
    • Memory retention timers on
    • Register retention

    Of the 4 power down modes, only the register retention mode will not cause a system reset on wakeup. All registers and RAM retain data as before the power down. After wakeup the program continue to run from where it was put to sleep, in addition the wakeup interrupt will execute if enabled.

    The memory retention mode will cause a system reset, however part of the RAM will retain data, but all register values are lost (including nRF radio). The memory retention mode can be useful to keep data for the application, while using less power than register retention mode.

    The deep sleep mode use the least amount of power consumption and also cause system reset. The only wakeup source is wakeup from pin, but this is sufficient for a remote control or other wakeup on keypress application.

    For more details on wakeup options and power consumption see the nRF24LE1 product specification.

    How to setup memory retention timers on, on the nRF24LE1?

    /*
    * An nRF24LE1 MEMORY RETENTION TIMER ON example application
    */
    
    #include <Nordic\reg24le1.h>
    #include <stdint.h>
    #include "hal_clk.h"
    #include "hal_rtc.h"
    
    uint8_t xdata toggle;
    
    void mcu_init(void)
    {
    // XOSC32K input
    P0DIR = 0x03;
    P1DIR = 0x00;
    P2DIR = 0x00;
    P3DIR = 0x00;
    
    P0 = 0x00;
    P1 = 0x00;
    P2 = 0x00;
    P3 = 0x00;
    
    // Open latch
    OPMCON = 0x00;
    }
    
    void wakeup_tick() interrupt INTERRUPT_TICK
    {
    // Toggle output on wakeup
    P02 = toggle;
    toggle = !toggle;
    }
    
    void main(void)
    {
    mcu_init();
    
    // If wakeup from tick, turn on LED
    if(PWRDWN & 0x40)
    {
    IEN1 = 0x20;
    EA = 1;
    // Go to standby mode and wait for RTC interrupt
    PWRDWN = 0x07;
    // Clear power down
    PWRDWN = 0x00;
    }
    else
    {
    // Init RTC timer
    hal_rtc_start(false);
    hal_clklf_set_source(HAL_CLKLF_XOSC32K);
    hal_rtc_set_compare_mode(HAL_RTC_COMPARE_MODE_0);
    hal_rtc_set_compare_value(0x7FFF);
    hal_rtc_start(true);
    }
    
    // Lock latch
    OPMCON |= 0x02;
    
    // Memory retention mode timer on, system reset on wakeup
    PWRDWN = 0x03;
    while(1);
    }
    

    How to setup register retention mode on the nRF24LE1?

    /*
    * An nRF24LE1 REGISTER RETENTION example application
    */
    
    #include <Nordic\reg24le1.h>
    
    void mcu_init(void)
    {
    // Wake up on pin P2.1 active-high
    WUOPC0 = 0x02;
    
    P0 = 0x00;
    P1 = 0x00;
    P2 = 0x00;
    P3 = 0x00;
    
    P0DIR = 0x00;
    P1DIR = 0x00;
    P2DIR = 0x02;
    P3DIR = 0x00;
    }
    
    void wakeup_irq() interrupt INTERRUPT_WUOPIRQ
    {
    // Turn on LED
    P22 = 1;
    }
    
    void main(void)
    {
    mcu_init();
    
    IEN1 = 0x08;
    EA = 1;
    
    while(1)
    {
    // Push button to go to power down mode, release button to wakeup
    while(P21);
    // Turn off LED
    P22 = 0;
    // Register retention mode
    PWRDWN = 0x04;
    // Clear power down
    PWRDWN = 0x00;
    
    }
    }
    

    How to setup deep sleep on the nRF24LE1?

    /*
    * An nRF24LE1 DEEP SLEEP example application
    */
    
    #include <Nordic\reg24le1.h"
    
    void mcu_init(void)
    {
    P0 = 0x00;
    P1 = 0x00;
    P2 = 0x00;
    P3 = 0x00;
    
    P0DIR = 0x00;
    P1DIR = 0x00;
    P2DIR = 0x02;
    P3DIR = 0x00;
    
    // Open latch
    OPMCON = 0x00;
    }
    
    void main(void)
    {
    mcu_init();
    
    // If wakeup from pin, turn on LED and clear PWRDWN
    if(PWRDWN & 0x80)
    {
    P02 = 1;
    PWRDWN = 0;
    }
    
    // Wake up on pin P2.1 active-high
    WUOPC0 = 0x02;
    
    // Push button to go to power down mode, release button to wakeup
    // Deep sleep, cause system reset on wakeup (release pin P2.1)
    while(P21);
    
    // Lock latch
    OPMCON |= 0x02;
    
    PWRDWN = 0x01;
    
    while(1);
    }
    

    How to setup register retention mode timer on, on the nRF24LE1?

    /*
    * An nRF24LE1 REGISTER RETENTION TIMER ON example application
    */
    
    #include <Nordic\reg24le1.h>
    #include "hal_clk.h"
    #include "hal_rtc.h"
    
    void mcu_init(void)
    {
    P0CON = 0x70; // Disable digital input buffer, pin used for 32kHz.
    P0CON = 0x71; // Disable digital input buffer, pin used for 32kHz.
    
    P0DIR = 0x03; // Two pins used for 32 kHz XO.
    P1DIR = 0x00;
    P2DIR = 0x00;
    P3DIR = 0x00;
    
    P0 = 0x00;
    P1 = 0x00;
    P2 = 0x00;
    P3 = 0x00;
    }
    
    void wakeup_tick() interrupt INTERRUPT_TICK
    {
    P02 = !P02;
    }
    
    void main(void)
    {
    mcu_init();
    
    hal_rtc_start(false);
    hal_clklf_set_source(HAL_CLKLF_XOSC32K);
    hal_rtc_set_compare_mode(HAL_RTC_COMPARE_MODE_0);
    hal_rtc_set_compare_value(0x7FFF);
    hal_rtc_start(true);
    
    // Wait for the 32kHz to startup (change phase)
    while((CLKLFCTRL&0x80)==0x80);
    while((CLKLFCTRL&0x80)!=0x80);
    
    IEN1 = 0x20;
    EA = 1;
    
    while(1)
    {
    // Register retention mode
    PWRDWN = 0x04;
    // Standby mode (wait for interrupt)
    PWRDWN = 0x07;
    // Clear PWRDWN
    PWRDWN = 0x00;
    // Continue to run code
    P03 = !P03;
    };
    }
    

    How to setup the UART on the nRF24LE1?

    /*
    * An nRF24LE1 UART example application
    */
    
    #include <Nordic\reg24le1.h>
    #include <hal_uart.h>
    
    void main(void)
    {
    uint8_t temp_char;
    
    // UART IO setup (Depends on package type, 7x7mm)
    // RXD input, TXD output
    P1DIR = 0xFE;
    
    // Init UART
    hal_uart_init(UART_BAUD_57K6);
    EA = 1;
    
    // Loopback
    while(1)
    {
    temp_char = hal_uart_getchar();
    hal_uart_putchar(temp_char);
    }
    }
    

    Are there other examples?

    https://devzone.nordicsemi.com/f/nordic-q-a/38814/how-to-set-nrf24le1-in-register-retention-with-analog-comparator-wakeup-sample-code-needed-please-help/150064#150064 

    Also check out the nRFgo SDK v2.3 that is the latest supporting the nRF24-series:
    https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF24-series

  • Hi
    thanks for your help, your code can work well.
    now I have an other question, can I wakeup from TICK and also from inetrupt (IRQ) simultaneously on register retention mode ?

Reply Children
Related