This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Trigger lpcomp sampling doesn´t work

Hello,

I try to modify the lpcomp example from the Nordic SDK to trigger the sampling of the lpcomp manually. I have added the following code:

lpcomp_init();

NRF_LOG_INFO("LPCOMP driver usage example started.");

nrf_lpcomp_task_trigger(NRF_LPCOMP_TASK_START);
nrf_lpcomp_task_trigger(NRF_LPCOMP_TASK_SAMPLE);
while(!nrf_lpcomp_event_check(NRF_LPCOMP_EVENT_READY));
Result = NRF_LPCOMP->RESULT;

I use AIn3 (GPIO 5) as input for the lpcomp and the input voltage is 2.4 V. The limit is set to 4/8 Vcc, but the result is 0 and not 1 as expected.

What is the issue with this code?

Parents Reply
  • Hi Kenneth,
    it seems to work now. I think there was an issue with the debugger because I got the correct results after attaching an LED to the result of the lpcomp. I use the initialization from the sdk example with the following loop:

        while (true)
        {
            NRF_LPCOMP->TASKS_SAMPLE=1;
    	    while(!nrf_lpcomp_event_check(NRF_LPCOMP_EVENT_READY));
            if(NRF_LPCOMP->RESULT)
            {
                bsp_board_led_on(BSP_BOARD_LED_1);
            }
            else
            {
                bsp_board_led_off(BSP_BOARD_LED_1);
            }
        }

Children
No Data
Related