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

nrf51 lpcomp doesn't work

Hi, this is how I initialize and enable LPCOMP

   nrf_drv_lpcomp_config_t lpcompconfig = {
     {NRF_LPCOMP_REF_SUPPLY_SEVEN_EIGHT, NRF_LPCOMP_DETECT_CROSS},
      APP_IRQ_PRIORITY_LOW,
      NRF_LPCOMP_INPUT_7};
   nrf_drv_lpcomp_init(&lpcompconfig, &lpcomphandler);
   nrf_drv_lpcomp_enable();

However, my

void lpcomphandler(nrf_lpcomp_event_t event);

is never called when I manually toggle P0.06 pin of nrf51 from GND to VCC, or from VCC to GND.

No matter whether I initialize and enable LPCOMP before or after softdevice initialization.

I use SDK9.0.0.

Can you please help?

Parents
  • I used custom low level LPCOMP driver (not the one included in SDK):

    void LPCOMP_init(void)
    {	
    	NRF_LPCOMP->INTENSET = LPCOMP_INTENSET_UP_Msk;
    	NVIC_EnableIRQ(LPCOMP_IRQn);	
    
    	NRF_LPCOMP->REFSEL |= (LPCOMP_REFSEL_REFSEL_SupplySevenEighthsPrescaling << LPCOMP_REFSEL_REFSEL_Pos);
    	NRF_LPCOMP->PSEL |= (LPCOMP_PSEL_PSEL_AnalogInput7 << LPCOMP_PSEL_PSEL_Pos);
    
    	NRF_LPCOMP->ENABLE = LPCOMP_ENABLE_ENABLE_Enabled;	
       NRF_LPCOMP->TASKS_START = 1;
    }
    

    Now LPCOMP works for me. I have no clue why it doesn't work with SDK driver.

Reply
  • I used custom low level LPCOMP driver (not the one included in SDK):

    void LPCOMP_init(void)
    {	
    	NRF_LPCOMP->INTENSET = LPCOMP_INTENSET_UP_Msk;
    	NVIC_EnableIRQ(LPCOMP_IRQn);	
    
    	NRF_LPCOMP->REFSEL |= (LPCOMP_REFSEL_REFSEL_SupplySevenEighthsPrescaling << LPCOMP_REFSEL_REFSEL_Pos);
    	NRF_LPCOMP->PSEL |= (LPCOMP_PSEL_PSEL_AnalogInput7 << LPCOMP_PSEL_PSEL_Pos);
    
    	NRF_LPCOMP->ENABLE = LPCOMP_ENABLE_ENABLE_Enabled;	
       NRF_LPCOMP->TASKS_START = 1;
    }
    

    Now LPCOMP works for me. I have no clue why it doesn't work with SDK driver.

Children
Related