-
-
Notifications
You must be signed in to change notification settings - Fork 90
Description
Hey,
I'm using Esp idf v5.3.1 and ESP32-S3 and master branch of the library.
The direction toggle in the RMT module is not working correctly because of the implementation of LL_TOGGLE_PIN.
gpio_ll_set_level(&GPIO, (gpio_num_t)dirPin, \
gpio_ll_get_level(&GPIO, (gpio_num_t)dirPin) ^ 1)
"gpio_get_level"" will always return 0 if the gpio is configured as output.
IDF Documentation Link:
https://docs.espressif.com/projects/esp-idf/en/v5.3.2/esp32/api-reference/peripherals/gpio.html#_CPPv414gpio_get_level10gpio_num_t
Looking through the implementation down the line gpio_get_level will call gpio_ll_get_level so the hint also holds for gpio_ll_get_level.
This is also true for idf v5.4.
The problem is, that successive moveTo commands will not change direction if first moving with dirPin=HIGH and then moving with dirPin=LOW since the direction change is implemented in the RMT layer that uses LL_TOGGLE_PIN. The error only appears if the next moveTo call is before the previous one finishes.
I fixed it locally for me by replacing LL_TOGGLE_PIN in StepperISR_idf5_esp32_rmt.cpp
with something like this:
static void toggleDir(const StepperQueue* queue, const queue_entry* e) {
if (e->countUp) {
gpio_ll_set_level(&GPIO, (gpio_num_t)queue->dirPin,
queue->dirHighCountsUp);
} else {
gpio_ll_set_level(&GPIO, (gpio_num_t)queue->dirPin,
!queue->dirHighCountsUp);
}
}