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

s110 LPCOMP Interrupt not working

I have scoured the internet for solutions, and documentation. Everything that I've found has to do with ADC, so I thought that I would just convert it to the LPCOMP(they're intrinsically linked). I have initialised the IRQ correctly. I have also verified that the down event triggers, i have attached my code and a screen shot of the registers. Setting a breakpoint in the IRQ handler never breaks. The LEDs do not ever turn on/flash. This code is setup for GCC, but compiles in ARM and has the same issue(You need to change the name of the IRQ handler from LPCOMP_IRQHandler to LPCOMP_COMP_IRQHandler). Neither compiler nor debugger fixes the issue. Using SDK V6, S110 V7.

static void lpcomp_init(void){
    NRF_LPCOMP->INTENSET = LPCOMP_INTENSET_DOWN_Enabled << LPCOMP_INTENSET_DOWN_Pos ;
    sd_nvic_SetPriority(LPCOMP_IRQn, NRF_APP_PRIORITY_LOW);
	sd_nvic_EnableIRQ(LPCOMP_IRQn);
	NRF_LPCOMP->REFSEL = LPCOMP_REFSEL_REFSEL_SupplyThreeEighthsPrescaling << LPCOMP_REFSEL_REFSEL_Pos;
	NRF_LPCOMP->PSEL = LPCOMP_PSEL_PSEL_AnalogInput6 << LPCOMP_PSEL_PSEL_Pos;
	NRF_LPCOMP->ENABLE = LPCOMP_ENABLE_ENABLE_Enabled;
	NRF_LPCOMP->POWER = 1;
	NRF_LPCOMP->TASKS_START = 1;
}

void LPCOMP_IRQHandler(void){
///get the time since the measurement was started
uint8_t time_elapsed = read_sensor_timer();
static uint8_t switcher = 0;
if(switcher){
	nrf_gpio_pin_set(CONNECTED_LED_PIN_NO);
	nrf_gpio_pin_clear(ADVERTISING_LED_PIN_NO);
}else{
	nrf_gpio_pin_set(ADVERTISING_LED_PIN_NO);
	nrf_gpio_pin_clear(CONNECTED_LED_PIN_NO);

}
switcher ^= 1;

sensor_data[sensor_data_ptr++] = time_elapsed;

//Release the external crystal
	sd_clock_hfclk_release();
}

image description

Parents Reply Children
No Data
Related