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

why interrupts can't trigger sometimes

SDK14.0 , s132_nrf52_5.0.0_softdevice, computer platform:  windows 7

//----------------------------------------------------------------------------------

I use one motor to drive one object move back and forth in a straight line, with two hall ic(XC3202) at the boundary points at both ends. The motor turn when the object reaches one detecting point.

I use interrupt to detect the object reach the boundary point(the hall ic), but finally i found the interrupt sometimes lost, especially when the motor speed is high.

//----------------------------------

void hall_ic_detect_init(void)

{

nrf_drv_gpiote_in_config_t in_config1 = GPIOTE_CONFIG_IN_SENSE_HITOLO(false);
in_config1.pull = NRF_GPIO_PIN_PULLUP;
err_code = nrf_drv_gpiote_in_init(HAL_PIN1, &in_config1, hall_pin1_handler);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_gpiote_in_init(HAL_PIN2, &in_config1, hall_pin2_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(HAL_PIN1, true);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(HAL_PIN2, true);
APP_ERROR_CHECK(err_code);

}

void hall_pin1_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{

     if(pin == HAL_PIN1 && action == GPIOTE_CONFIG_POLARITY_HiToLo)
     {
              left_detect_flag = 1;
     }

}

void hall_pin2_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{

       if(pin == HAL_PIN2 && action == GPIOTE_CONFIG_POLARITY_HiToLo)
       {
               right_detect_flag = 1;
        }

}

When the motor runs with a high speed ,the hall_pin1_handler() and hall_pin2_handler() can't trigger sometimes. I am puzzled, maybe the softdevice block it? or else reason?

Parents
  • Hi,

    I am pretty sure that at high speed you are getting another high priority interrupt at high frequency which is masking these two interrupt handlers. Make sure that any other high priority interrupts do very little processing in their ISR.

     

    I am puzzled, maybe the softdevice block it? or else reason?

    It is possible, if you are doing a lot of radio activity based on the speed of the motor. Very hard to say at this point. But it is possible that a lot of radio activity from softdevice could mask  hall_pin1_handler and hall_pin2_handler if your application is keeping softdevice busy.

  • Hi,  thanks for your answer, Susheel Nugura! now what can I do to solve the problem, can be informed immediately when the object reach the hall ic, with the softdevice  be used at the same time. Now we use ble only for dfu, I think most of the time the softdevice or the radio activity shouldn't busy. Do you have any good idea?

    Thank you very much!

Reply Children
Related