Hello list,
Starting from the ble_app_uart example I am trying to create 2 dc motor control loops. Instead of using the uart I use the scheduler to create a simple command loop over BLE to control the app.
There is only 1 QDEC device so I need a software decoder, but that only works when the motor is turning slowly because very soon it seems that interrupts are being missed!
I use one of the encoder inputs to create an interrupt on each transition using GPIOTE. The handler is as follows:
void encoder1Event(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { if (nrf_drv_gpiote_in_is_set(enca1)) { if (!nrf_gpio_pin_read(enca2)) { encoder1--; nrf_gpio_pin_set(LED_DL3_BLU); } else { nrf_gpio_pin_clear(LED_DL3_BLU); encoder1++; } } else { if (!nrf_gpio_pin_read(enca2)) { encoder1++; } else { encoder1--; } } }
Note the LED added for debugging. If the motor is running in one direction, the LED should be continuously the same, say ON.
But as soon as the interrupts are coming as fast as one per millisecond, it seems that interrupts are being missed (a lot!) as shown with the led. This is also shown via the command loop in that encoder1 does not continuously increases as it should in this case. A scope reveals that the encoder signals are as they should be.
I thinks that the only thing that could to this is the softdevice, correct?
Does this mean that interrupts are blocked for 1 msec on a regular base by the softdevice?
Thanks in advance, Sietse