Hi,
I´m using SDK v16 on a custom board and try to implement the wake up functionality of the low power comparator.
In order to describe the system as clearly as possible, a brief explanation of its use.
I connected the analog input 0 to a piezoelectric sensor and read its signals. Now I want also to wake up the system using these signals.
From the documentation LPCOMP it seems pretty straight forward - configure PSEL, REFSEL and EXTREFSEL before ENABLE
and then call sd_power_system_off().
This is confirmed in the answer here and the mentioned examples in this answer and this older one. I´m basing my current implementation
of the example provided by the SDK.
For now i don´t need any processing happen after the wakeup, a simple system reboot would be fine. So i just reset the event flag in the event handler.
static void lpcomp_event_handler(nrf_lpcomp_event_t event) { NRF_LPCOMP->EVENTS_READY = 0; }
As for the configuration of the LPCOMP i tried to use the example on "out of the box" just configuring the analog input to match my system.
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_0; // initialize LPCOMP driver, from this point LPCOMP will be active and provided // event handler will be executed when defined action is detected err_code = nrf_drv_lpcomp_init(&config, lpcomp_event_handler); APP_ERROR_CHECK(err_code); nrf_drv_lpcomp_enable(); }
Since this was not successful, I tried a customized variant in which I did the configuration explicitly.
static void lpcomp_init(void) { uint32_t err_code; nrf_drv_lpcomp_config_t config; config.input = NRF_LPCOMP_INPUT_0; nrf_lpcomp_config_t hal_config; hal_config.reference = LPCOMP_REFSEL_REFSEL_Ref3_16Vdd; hal_config.detection = LPCOMP_ANADETECT_ANADETECT_Cross; config.hal = hal_config; config.interrupt_priority = 3; // initialize LPCOMP driver, from this point LPCOMP will be active and provided // event handler will be executed when defined action is detected err_code = nrf_drv_lpcomp_init(&config, lpcomp_event_handler); APP_ERROR_CHECK(err_code); nrf_drv_lpcomp_enable(); }
As far as I understand it up to now, this should be the recommended procedure. After the initialization I call sd_power_system_off().
The system powers off as expected, but can´t be woken up by any means.
I suspect I have a fundamentally wrong understanding of the usage or do not configure the system correctly.
I would be very grateful for general information on the use of LPCOMP, as well as concrete solutions for this particular application.
I would also be grateful for any advice on how to proceed in such a case in order to work out a solution independently.