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

How to set NRF24LE1 in register retention with analog comparator wakeup? Sample code needed. Please help.

I want to set up nrf24le1 in register retention mode with analog comparator wake up. The moment it wakes up it should do few ADC conversions and then again go back to sleep. I could not find much information on this or any example code. I just found this:

hal_ancmp_set_input_channel(8);//P1.0
hal_ancmp_set_ref_voltage_scale(0x01);//50%
hal_ancmp_set_reference(0);
hal_ancmp_enable(true);
PWRDWN=0x04

from this thread here: https://devzone.nordicsemi.com/f/nordic-q-a/20741/how-to-wakeup-with-analogcomparator-on-nrf24le1

But I do not know how that code works or how to change it to do ADC conversions on wake up and then go back to power saving mode. Someone please help.

  • I can see that the module does not have a 32kHz crystal. This means that the following line of code will not work:

    hal_clklf_set_source(HAL_CLKLF_XOSC32K);   

    Instead you should use:

    hal_clklf_set_source(HAL_CLKLF_RCOSC32K);   

    Since you are not using HAL_CLKLF_XOSC32K, you also need to modify:

    //P0CON = 0x70; // Disable digital input buffer, pin used for 32kHz. // Should not be used since there is no 32kHz XO
    //P0CON = 0x71; // Disable digital input buffer, pin used for 32kHz. // Should not be used since there is no 32kHz XO
    P0CON = 0x73; // Disable digital input buffer, pin used for ADC // Can be used

    //P0DIR = 0x07; // Two pins used for 32 kHz XO, one pin for ADC. // Should not be used since there is no 32kHz XO
    P0DIR = 0x04; // One pin for ADC. // Change to this

Related