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

Please help me error LPCOMP wakeup from system off

please help me
static void lpcomp_handler(nrf_lpcomp_event_t event)
{
    NRF_LPCOMP->EVENTS_DOWN = 0;
    NRF_LPCOMP->EVENTS_UP = 0;
    NRF_LPCOMP->EVENTS_CROSS = 0;
}
void lpcomp_init(void)
{
    uint32_t err_code;
    nrf_gpio_pin_clear(NRF_LPCOMP_INPUT_2);

    nrf_drv_lpcomp_config_t config = NRF_DRV_LPCOMP_DEFAULT_CONFIG;
    config.hal.reference = NRF_LPCOMP_REF_SUPPLY_4_8;
    config.hal.hyst = NRF_LPCOMP_HYST_50mV;
    config.input = NRF_LPCOMP_INPUT_2;

#ifdef USE_ANADETECT
    //config.hal.detection = NRF_LPCOMP_DETECT_UP;
#endif
    // init
    err_code = nrf_drv_lpcomp_init(&config, lpcomp_handler);
    APP_ERROR_CHECK(err_code);
    // enable
    nrf_drv_lpcomp_enable();
    // Lpcomp ready
    NRF_LPCOMP->TASKS_START = 1;
    while(NRF_LPCOMP->EVENTS_READY == 0);
    NRF_LPCOMP->EVENTS_READY = 0;

#ifdef USE_ANADETECT
    sd_power_system_off();
#endif
}

I was working with LPCOMP when I set up lpcomp like above, even though I have set my comparator but just impacting anything on the AIN2 pin will wake up the chip even though I don't use anadetect signal. So where is my problem? I am using nrf52840 dk and sdk 16

Parents
  • Hi,

    Avoid mixing the usage of the driver and the writing directly to the register. Try something like this:

    static void event_handler(nrf_lpcomp_event_t event)
    {
    
    }
    
    static void lpcomp_init(void)
    {
        uint32_t err_code;
    
        nrf_drv_lpcomp_config_t config = NRF_DRV_LPCOMP_DEFAULT_CONFIG;
        config.input = NRF_LPCOMP_INPUT_3;
        config.hal.detection = NRF_LPCOMP_DETECT_UP;
    
        err_code = nrf_drv_lpcomp_init(&config, event_handler);
        APP_ERROR_CHECK(err_code);
        nrf_drv_lpcomp_enable();
    }
    
    int main(void)
    {
        
        lpcomp_init();
        nrf_power_system_off();
    }
    

Reply
  • Hi,

    Avoid mixing the usage of the driver and the writing directly to the register. Try something like this:

    static void event_handler(nrf_lpcomp_event_t event)
    {
    
    }
    
    static void lpcomp_init(void)
    {
        uint32_t err_code;
    
        nrf_drv_lpcomp_config_t config = NRF_DRV_LPCOMP_DEFAULT_CONFIG;
        config.input = NRF_LPCOMP_INPUT_3;
        config.hal.detection = NRF_LPCOMP_DETECT_UP;
    
        err_code = nrf_drv_lpcomp_init(&config, event_handler);
        APP_ERROR_CHECK(err_code);
        nrf_drv_lpcomp_enable();
    }
    
    int main(void)
    {
        
        lpcomp_init();
        nrf_power_system_off();
    }
    

Children
Related