# ESP32 - Stepper motor using freeRTOS task

**URL:** <https://forums.freertos.org/t/esp32-stepper-motor-using-freertos-task/14354>\
**Category:** Espressif\
**Created:** [January 31, 2022, 3:08pm UTC](https://forums.freertos.org/t/esp32-stepper-motor-using-freertos-task/14354 "2022-01-31T15:08:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alelor](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@alelor](https://forums.freertos.org/u/alelor)\
**Post date:** [January 31, 2022, 3:08pm UTC](https://forums.freertos.org/t/esp32-stepper-motor-using-freertos-task/14354/1 "2022-01-31T15:08:01Z")

</div>

Hi,  
I have to drive a stepper motor with my esp32, with a frequency that requires a delay below milliseconds (for example 100 microseconds). The esp32 has WiFi and ESP-NOW active at the same time, receiving some data from another esp32. My idea was to create a freeRTOS task for the stepper motor on core 0, so that core 1 can run WiFi ESP-NOW, but I have a hard time managing microseconds delay by doing so. I know that the vTaskDelay() cannot go higher than 1kHz.  
Any suggestions? Thanks in advance!

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [January 31, 2022, 5:10pm UTC](https://forums.freertos.org/t/esp32-stepper-motor-using-freertos-task/14354/2 "2022-01-31T17:10:13Z")

</div>

> [@alelor](#):
>
> I know that the vTaskDelay() cannot go higher than 1kHz.

This isn’t true unless this is an MCU limit. Check with this very concise explanation:

> [@How to use microsecond function calls in freeRTOS?](https://forums.freertos.org/t/how-to-use-microsecond-function-calls-in-freertos/8700/4):
>
> The issue with high tick rates isn’t that FreeRTOS itself has problems, but that running the tick at a high frequency means the tick interrupt and the scheduler get run often, and use up significant CPU resources, and at some point, they will use up all the CPU time so nothing is left to run your program. What does have a problem are some of the ‘convenience’ macros that convert time periods to ticks, those don’t work right if your tick period isn’t an integral number of milliseconds. Another p…

---

<div class="post-metadata">

**Author:** ![alelor](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@alelor](https://forums.freertos.org/u/alelor)\
**Post date:** [February 1, 2022, 3:05pm UTC](https://forums.freertos.org/t/esp32-stepper-motor-using-freertos-task/14354/3 "2022-02-01T15:05:38Z")

</div>

Thank you for the suggestion! 😀

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [February 2, 2022, 6:27pm UTC](https://forums.freertos.org/t/esp32-stepper-motor-using-freertos-task/14354/4 "2022-02-02T18:27:57Z")

</div>

Another option, which is likely better, is rather than trying to use the tick to time the steps, us another timer in the system for this timing, and either signal a task, or just do the step in the ISR. This allows changing the rate with a fine scale to accelerate.
