Is there a way to disable FreeRTOS ticks on one core?
-
- Posts: 16
- Joined: Wed Jul 08, 2020 8:33 pm
Is there a way to disable FreeRTOS ticks on one core?
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!
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!
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Is there a way to disable FreeRTOS ticks on one core?
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.
-
- Posts: 16
- Joined: Wed Jul 08, 2020 8:33 pm
Re: Is there a way to disable FreeRTOS ticks on one core?
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.ESP_Sprite wrote: ↑Wed Oct 07, 2020 6:55 amGeneral 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.
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Is there a way to disable FreeRTOS ticks on one core?
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?
-
- Posts: 16
- Joined: Wed Jul 08, 2020 8:33 pm
Re: Is there a way to disable FreeRTOS ticks on one core?
Hmm, I'll look into that..ESP_Sprite wrote: ↑Wed Oct 07, 2020 2:33 pmYou 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?
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).
-
- Posts: 16
- Joined: Wed Jul 08, 2020 8:33 pm
Re: Is there a way to disable FreeRTOS ticks on one core?
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!
-
- Posts: 16
- Joined: Wed Jul 08, 2020 8:33 pm
Re: Is there a way to disable FreeRTOS ticks on one core?
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?
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
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
-
- Posts: 16
- Joined: Wed Jul 08, 2020 8:33 pm
Re: Is there a way to disable FreeRTOS ticks on one core?
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.
- Attachments
-
- GENESIS_IMPLEMENTATION.c
- (7.03 KiB) Downloaded 621 times
Re: Is there a way to disable FreeRTOS ticks on one core?
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.
Who is online
Users browsing this forum: Google [Bot] and 91 guests