Page 1 of 1
Is there a way to disable FreeRTOS ticks on one core?
Posted: Wed Oct 07, 2020 2:21 am
by Derf Jagged
I have a task running on the second core that flips GPIOs on and off and takes between 900ns and 1500ns about 4 times per second. Unfortunately, the FreeRTOS scheduler preempts this task every 1ms and causes a large delay and making it take too long.
Is there a way that I can either:
- Disable the FreeRTOS scheduler completely on one core so it only runs my single task?
- Disable FreeRTOS ticks on the second core and manually do them?
- Disable FreeRTOS completely via menuconfig but still be able to run my task and use the GPIO operations?
I won't be running any other tasks on this core. I see that I can change the tick rate in menuconfig, but I don't know what side effects would come from decreasing the tick rate.
Thanks!
Re: Is there a way to disable FreeRTOS ticks on one core?
Posted: Wed Oct 07, 2020 6:55 am
by ESP_Sprite
General advice: Don't bitbang GPIOs on the ESP32. The FreeRTOS tick timer isn't the only thing leading to jitter there: shared buses, RPC calls because of flashing etc, they can all influence timing. Rather, try to see if there's a hardware device that can generate the signal you need. For instance, it sounds like you're generating something PWM'ish here; you could look at the LEDC or MCPWM peripherals. Worst case, the RTC peripheral is really flexible in generating signals.
Re: Is there a way to disable FreeRTOS ticks on one core?
Posted: Wed Oct 07, 2020 1:20 pm
by Derf Jagged
ESP_Sprite wrote: ↑Wed Oct 07, 2020 6:55 am
General advice: Don't bitbang GPIOs on the ESP32. The FreeRTOS tick timer isn't the only thing leading to jitter there: shared buses, RPC calls because of flashing etc, they can all influence timing. Rather, try to see if there's a hardware device that can generate the signal you need. For instance, it sounds like you're generating something PWM'ish here; you could look at the LEDC or MCPWM peripherals. Worst case, the RTC peripheral is really flexible in generating signals.
Thanks for the reply. Would you have a recommendation for 8 pin digital parallel writes? My current setup works for my purposes seemingly for all times besides when FreeRTOS ticks (since it's such a long delay), but if there's a better option, that'd be great. I don't really know how any of the other hardware devices work.
Re: Is there a way to disable FreeRTOS ticks on one core?
Posted: Wed Oct 07, 2020 2:33 pm
by ESP_Sprite
You can possibly adjust the I2S parallel (LCD) mode to do that. There's no real driver in ESP-IDF for that though, although there are a fair few projects that use that mode out there. In general, what are you trying to do; what are you writing to?
Re: Is there a way to disable FreeRTOS ticks on one core?
Posted: Wed Oct 07, 2020 2:56 pm
by Derf Jagged
ESP_Sprite wrote: ↑Wed Oct 07, 2020 2:33 pm
You can possibly adjust the I2S parallel (LCD) mode to do that. There's no real driver in ESP-IDF for that though, although there are a fair few projects that use that mode out there. In general, what are you trying to do; what are you writing to?
Hmm, I'll look into that..
My project is emulating a Sega Genesis controller. My code waits for a low signal on the Select line, then writes out virtual button states on 7 separate pins, then does the same for when Select goes high. No one seems to know the exact threshold that you have to report by, but it seems to be within 2us (which the tick breaks if it happens while reporting).
Re: Is there a way to disable FreeRTOS ticks on one core?
Posted: Thu Oct 08, 2020 1:22 pm
by Derf Jagged
While I look into that, do you know any of the answers for the questions in the first post? It's so close to working perfectly!
Re: Is there a way to disable FreeRTOS ticks on one core?
Posted: Wed Oct 14, 2020 2:29 am
by Derf Jagged
In the end, after experimenting a lot with vTaskEndScheduler() and others, I found that just spawning my critical task on cpu1 and calling portENTER_CRITICAL() at the start worked so long as I turned off the Task Watchdog for cpu1. Works great, I can do GPIO manipulation in an infinite loop.
Re: Is there a way to disable FreeRTOS ticks on one core?
Posted: Mon Jan 25, 2021 6:20 pm
by matherp
Derf jagged
I've got the same requirement to allocate one core to a continuously looping task. Please could you share the code you used to create the critical task and lock it to a CPU
Many thanks
Re: Is there a way to disable FreeRTOS ticks on one core?
Posted: Sat Mar 13, 2021 9:14 pm
by Derf Jagged
matherp wrote: ↑Mon Jan 25, 2021 6:20 pm
Derf jagged
I've got the same requirement to allocate one core to a continuously looping task. Please could you share the code you used to create the critical task and lock it to a CPU
Many thanks
Sorry for the extremely late reply, I just dug this up in my open tabs. Hopefully this might help you or someone else. The "Select" task is the important one. You need to turn off the Task Watchdog for cpu1 in the ESP-IDF menuconfig.
Re: Is there a way to disable FreeRTOS ticks on one core?
Posted: Mon Apr 11, 2022 10:00 pm
by moefear85
on a side-note, checkout esp-iot-solution. it includes drivers for i2s in lcd-mode, making it easier to implement your own protocol without bitbanging. Other than that, you could use an attiny or atmega as a co-processor, and have that do the bitbanging. you'd only need the esp32 for wireless communication.