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