I want to use a comparator without interrupt.
The measurement is not time critical.
Therefore, I chose the LPCOMP.
For initialization I use the following code:
static void lpcomp_init(uint8_t ref) { nrf_lpcomp_config_t config; config.reference = (nrf_lpcomp_ref_t)ref; config.detection = NRF_LPCOMP_DETECT_CROSS; config.hyst = LPCOMP_HYST_HYST_Hyst50mV; // config LPCOMP, from this point LPCOMP will be active nrf_lpcomp_configure(&config); nrf_lpcomp_input_select(PIN_REGENSENSOR); nrf_lpcomp_enable(); }
For reading the value I use the following code:
uint8_t lpcomp_result; nrf_lpcomp_task_trigger(NRF_LPCOMP_TASK_SAMPLE); lpcomp_result = (uint8_t)nrf_lpcomp_result_get();
Although the input is approximately VDD I get the value 0 back.
How can I use the LPCOMP (or COMP) without interrupts?