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

unable to disable a GPIOTE Event using nrf_drv_gpiote_in_event_disable

Hello:

I need to disable an interrupt event outside the handler. During debugging when the nrf_drv_gpiote_in_event_disable function gets executed, the program seems to reset. I have also tried nrf_gpio_cfg_sense_set with NRF_GPIO_PIN_NOSENSE with the same results. I need to be able to enable and disable interrupt functions based on received modes from a central device. Any help will be greatly appreciated.

Regards,

  • Could you post some code snippets showing setup of GPIOTE and how/where you call nrf_drv_gpiote_in_event_disable?

  • void Configure_CDC_Interrupt(bool enable) { uint32_t err_code;

    	if(enable)
    	{
    			nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
    			err_code = nrf_drv_gpiote_in_init(CDC_INT_PIN, &in_config, CDC_interrupt_handler);
    			APP_ERROR_CHECK(err_code);
    			
    			nrf_drv_gpiote_in_event_enable(CDC_INT_PIN, true);
    	}
    	else
    	{
    //			nrf_drv_gpiote_in_event_disable(CDC_INT_PIN);
    			nrf_gpio_cfg_sense_set(CDC_INT_PIN, NRF_GPIO_PIN_NOSENSE);
    	}
    }
    void Configure_IMU_Interrupt(bool enable)
    {
    		uint32_t err_code;
    	
    		if(enable)
    		{
    				nrf_drv_gpiote_in_config_t in_config2 = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
    				in_config2.pull = NRF_GPIO_PIN_PULLDOWN;
    				in_config2.hi_accuracy = true;
    				err_code = nrf_drv_gpiote_in_init(IMU_INT1_PIN, &in_config2, IMU_interrupt_handler);
    				APP_ERROR_CHECK(err_code);	
    			
    				nrf_drv_gpiote_in_event_enable(IMU_INT1_PIN, true); 
    		}	
    		else
    		{		
                    //nrf_gpio_cfg_sense_set(IMU_INT1_PIN, NRF_GPIO_PIN_NOSENSE);
    
    				nrf_drv_gpiote_in_event_disable(IMU_INT1_PIN);									
    		}
    
    }
    

    The above 2 functions get called during the startup of the program. when I receive a BLE command to switch modes, I would call one of the above functions to disable the appropriate event. Can it be the program resets because of some error do to the event being(or has) triggered and the handler has not been executed when I try to disable it?

  • void CDC_interrupt_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { Read_CDC_Results();

    		CDC_Data_Filter();
    		
    		if (acquisition_mode != IMU_Data)		// IMU_Data mode is called in the IMU_interrupt handler
    			acquisition_mode_characteristic_update();
    }
    void IMU_interrupt_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
    		
                   IMU_timestamp_current_counter = NRF_RTC0->COUNTER;
    
    		IMU_timestamp_current_counter2 = out_gyroself(LSM6DS3_ACC_GYRO_TIMESTAMP0_REG,LSM6DS3_ACC_GYRO_TIMESTAMP1_REG);
    
    		IMU_timestamp_current_counter2 |= (spi_gpio_test_rx(LSM6DS3_ACC_GYRO_TIMESTAMP2_REG,SPI_READ,0x00) << 16);
    
    	
    		if (IMU_timestamp_current_counter2 >= 0xFF0000)
    				spi_gpio_test_rx(LSM6DS3_ACC_GYRO_TIMESTAMP2_REG, SPI_WRITE, 0xAA); 
    	
    					
    		if ((acquisition_mode == Standard_Aquisition) || (acquisition_mode == IMU_Data) || (acquisition_mode == All_Measurement))
    
    				Get_IMU_Data(1); // read Accel
    		
    		if ((acquisition_mode == IMU_Data) || (acquisition_mode == All_Measurement))
    
    				Get_IMU_Data(0); // read the Gyro Data
    		
    		imu_data_byte_convertion();
    		
    		if (acquisition_mode == IMU_Data)
    			acquisition_mode_characteristic_update();
    }
    

    both handlers read data from the SPI bus. any help is greatly appreciated.

  • Have you tried debugging using this method, to see if any error codes are returned?

Related