This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

unable to use low-power comparator

I'm trying to use the low-power comparator. 

I've started up the comparator using "lpcomp_init()".

Following that, I wish to have a sample event, and then log the result register. I can tie the pin to 0 or 1, so I should be able to change the input and see the RESULT register change in the log. Can you let me know what this code is missing?

=====   extract from main starts here  =======

NRF_LOG_INFO("start comparator set-up.");
lpcomp_init(); // turn on low power comparator.

while(1)
{
NRF_LPCOMP->TASKS_SAMPLE = 1; // cause a sample event for the op amp
nrf_delay_ms(1); // short delay
uint32_t lpcomp_result_register = NRF_LPCOMP->RESULT; // read result

NRF_LOG_INFO("comp: %d", lpcomp_result_register); // log result
NRF_LOG_FLUSH();
}

Thanks,

Stephen

Related