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

2 GPIOTE Interrupts, Only one of the handler functions being hit

Hello:

I dont seem to understand what the problem is. I have 2 external ICs, one is an IMU and the other is a CDC. Both have interrupt pins connected to the nordic nRF52832 pins 12 and 26. I configure the pins as shown bellow.

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, in_pin_handler);

APP_ERROR_CHECK(err_code);

nrf_drv_gpiote_in_config_t in_config2 = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);

in_config2.pull = NRF_GPIO_PIN_PULLDOWN;

err_code = nrf_drv_gpiote_in_init(IMU_INT1_PIN, &in_config2, IMU_INT1_pin_handler);

APP_ERROR_CHECK(err_code);

nrf_drv_gpiote_in_event_enable(IMU_INT1_PIN, true);

nrf_drv_gpiote_in_event_enable(CDC_INT_PIN, true);

I can see the in_pin_handler being hit while the IMU_INT1_pin_handler does not. I do not have any other high accuracy events configured. The IMU interrupt is triggered aprox. at 104 Hz while the CDC is at 100 Hz. Can anyone please help explain what I am doing wrong here. Your time and effort will be greatly appreciated.

Regards,

  • Hi,

    I don't see anything wrong with the code you posted. Note that you have pulldown on IMU_INT1_PIN, but not on CDC_INT_PIN. When CDC_INT_PIN goes from high to low, the in_pin_handler should be triggered and when IMU_INT1_PIN goes from low to high IMU_INT1_pin_handler should be triggered.

    You should check with a oscilloscope/logic analyzer that the IMU_INT1_PIN pin actually goes high, if not the interrupt will of course not be triggered.

  • Hello:

    Thanks for your reply. I have checked the IMU_INT1_PIN with a oscilloscope and it functions as it should. Is it possible the issue is I have 2 different handler names for the different IRQs?

  • What SDK version are you using ? Are you using the SoftDevice/BLE? Try lowering the GPIOTE_CONFIG_IRQ_PRIORITY in sdk_config.h, to e.g. to 3. If you are using SDK 11 or lower use nrf_drv_config.h instead of sdk_config.h. You can also test it without the internal pulldown, and see if that helps. Note that the pin need to reach voltage of 0.7 * Vdd to be detected as "high".

    Also make sure that you are not running into any error-handlers, see here on how to debug.

  • 11, yes I am using a softdevice/ble. lowering the priority did nothing. I also tested it without the internal pull down and same results. I am going nuts, please help. BTW does the handler function names need to be the same for both INTs?

  • No, the function names can be different, i.e. you can use both in_pin_handler and IMU_INT1_pin_handler. I have tried reproducing the issue using SDK 11, but I’m not seeing any problems here. Please make sure that the IMU is connect to the correct nRF-pin(IMU_INT1_PIN). Did you try debug mode? Exactly how are you checking if the interrupt is triggered?

    Also make sure that nothing is reconfiguring the pin later in you program. i.e. check that GPIOTE register and GPIO P0 register are correct.

Related