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?
Hi,
please look here for an example.
Hi dmitry, Many thanks for your example. But now I am having a problem: when I set up that LPCOMP pin AIN2 I turned off the anadetect signal, but as long as I have an impact on that pin, whatever my system wakes me up. know why?
Hi,
it's not my example, I just put a link here )
Do you mean that the system wakes up from SYSTEM OFF or WFE? As long as LPCOMP is enabled, it will wake up the system from WFE state on crossing threshold, but it should not do that from SYSTEM OFF when ANADETECT is not configured.
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();
}