Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motor task delayed scheduling causing 'crunchy' feeling (on LVGL branch) #159

Open
tonyherre opened this issue Apr 20, 2024 · 0 comments
Open

Comments

@tonyherre
Copy link

tonyherre commented Apr 20, 2024

Trying out the dev/lvgl branch, I was running into issues with the motor task seeming to get starved - it would feel quite 'crunchy' on the fine detents demo, and some printf debugging showed the main task loop was dropping to take 1.8-2ms averaged over a thousand loops, rather than the expected ~1ms.

After a lot of playing around with priorities and reading ESP-IDF docs on scheduling to try to understand how extra UI work on core0 could affect the motor task pinned to core1, it turned out to be the delay(1).
My reading of the ESP-IDF FreeRTOS docs on scheduling is that high load on Core0 will actually interfere with resolving timers accurately, so the motor task's delay(1) takes much more than a millisecond to resolve some of the time.

Workaround/solution: using delayMicroseconds(1000) in place of delay(1), as this is implemented as a busy loop: https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-misc.c#L206 so doesn't get affected by Core0 load. Surprisingly, the watchdog idle task still seems happy.

All testing on a Lilygo T-Micro32 Plus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant