Hi everyone, I'm having a problem as follows: I am wanting to use LPCOMP to wake up the nrf52840 from system off mode. So can anyone give me an idea of how to do that?
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;
//config.hal.detection = NRF_LPCOMP_DETECT_UP;
// 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;
sd_power_system_off();
}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;
//config.hal.detection = NRF_LPCOMP_DETECT_UP;
// 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;
sd_power_system_off();
}