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

interrupt sometime lost

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,

    Have you tested/considered using the .high_accuracy mode (IN_EVENT rather than PORT event)? You can enable it by passing 'True' to the GPIOTE_CONFIG_IN_SENSE_HITOLO() macro. It does increase the base current consumption by ~20uA, but guess it would be negligible compared what you use to power the motor. 

    BLE events can delay execution of lower priority ISRs, but not by much. Please refer to the "Bluetooth low energy processor usage patterns" in SDS if you want exact numbers (link).

      

Reply
  • Hi,

    Have you tested/considered using the .high_accuracy mode (IN_EVENT rather than PORT event)? You can enable it by passing 'True' to the GPIOTE_CONFIG_IN_SENSE_HITOLO() macro. It does increase the base current consumption by ~20uA, but guess it would be negligible compared what you use to power the motor. 

    BLE events can delay execution of lower priority ISRs, but not by much. Please refer to the "Bluetooth low energy processor usage patterns" in SDS if you want exact numbers (link).

      

Children
No Data
Related