This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
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

problem with gpiote interrupt

I ´m testing gpiote interrupt, i´m work with nrf51-dk, softdevice S110 and sdk 9.0.0.

I have a pin that receives a signal 0 all time, and it changes to 1 when I have to do some tasks, I declared pin as input, in init I say the configuracion of the interrupt, priority.

The thing is that I have a function that it makes a large amount of calculations, if I comment this fuction, i have 500 interrupts that are i have to receive but if i discomment function, the interrupt is about 250 and i don´t know why because I set priority to highest.

handler

void controlador_evento_interrupcion(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action){
	lecturas++;
}

init

void interrupt_pin_inicio(){
	uint32_t err_code;
	nrf_drv_gpiote_in_config_t configuracion;
	configuracion.is_watcher = false;
	configuracion.hi_accuracy = true;
	configuracion.pull = NRF_GPIO_PIN_PULLUP;
	configuracion.sense = NRF_GPIOTE_POLARITY_LOTOHI;
	
	NVIC_EnableIRQ(GPIOTE_IRQn);
	NVIC_SetPriority(GPIOTE_IRQn, 1);

	err_code = nrf_drv_gpiote_init();	
	//printf("Error: %zu ", err_code);

	err_code = nrf_drv_gpiote_in_init(pin_interrupcion_lectura, &configuracion, controlador_evento_interrupcion);
	//printf("Error: %zu ", err_code);

	nrf_drv_gpiote_in_event_enable(pin_interrupcion_lectura , true);
	//printf("Error: %zu ", err_code);
}

main declaration

	nrf_gpio_cfg_input(pin_interrupcion_lectura, NRF_GPIO_PIN_PULLUP);

Thank you.

  • FormerMember
    0 FormerMember

    Could you please elaborate a little more, what kind of function do you comment and uncomment? What do you want your device to do?

  • In main loop, I have a function that uses spi to send / read data and makes calculations, the problem I believe to happen is that i lose all gpiote interrupts when my board is sending or reading by spi.

    But I set spi interrupts with low priority:

    configuracion_SPI.SPI_PriorityIRQ = NRF_APP_PRIORITY_LOW;	//con softdevice
    

    And gpiote interrupts with high:

    NVIC_EnableIRQ(GPIOTE_IRQn);
    NVIC_SetPriority(GPIOTE_IRQn, 1);
    

    I need my device detects all gpiote interrupts while it uses spi.

  • nrf_drv_gpiote_init() will set the priority to GPIOTE_CONFIG_IRQ_PRIORITY, which may be APP_IRQ_PRIORITY_LOW (check this). Try to set the interrupt priority after the init function or change GPIOTE_CONFIG_IRQ_PRIORITY to APP_IRQ_PRIORITY_HIGH.

  • At the end, I have changed some part of my code, reducing delays, and others things and I now, it detects more gpiote interrupts, thank you.

Related