Adverse effects of CONFIG_FREERTOS_HZ = 1000?

DrMickeyLauer
Posts: 168
Joined: Sun May 22, 2022 2:42 pm

Adverse effects of CONFIG_FREERTOS_HZ = 1000?

Postby DrMickeyLauer » Sat May 20, 2023 12:18 pm

I'm working on the firmware of an ESP32C6-based CAN-Bus-Adapter for ECU reprogramming in vehicles. When talking to ECUs over CAN, it's pretty important to get the CAN-bus timing right. In order not to talk too fast (many ECUs are slow), the protocol provides an inter-frame-delay flow control of millisecond granularity.

I recently found out that with the default `CONFIG_FREERTOS_HZ = 100`, cooperative delays of less than 10ms are impossible, since, e.g., `vTaskDelay(2)` seems to return immediately.
I tried busy waiting 2000000µs with `esp_delay_us(2000000)`, but that always lead to asserts in the `esp_timer` task:

Code: Select all

Assert failed: prvProcessReceivedCommands timers.c:862 (xResult)
Now it looks like the only way(?) to get cooperative delays of millisecond-granularity is to bump the tick frequency to 1000Hz. I wonder which kind of adverse effects I'm going for if I do that. Does it really significantly reduce the overall performance (which I have read in some places)?

MicroController
Posts: 1709
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Adverse effects of CONFIG_FREERTOS_HZ = 1000?

Postby MicroController » Sat May 20, 2023 8:05 pm

DrMickeyLauer wrote:
Sat May 20, 2023 12:18 pm
I tried busy waiting 2000000µs with `esp_delay_us(2000000)`
You're busy-waiting for 2 seconds?!

DrMickeyLauer
Posts: 168
Joined: Sun May 22, 2022 2:42 pm

Re: Adverse effects of CONFIG_FREERTOS_HZ = 1000?

Postby DrMickeyLauer » Sat May 20, 2023 10:44 pm

Whoops… a couple of zeroes too many. That might have killed it.

MicroController
Posts: 1709
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Adverse effects of CONFIG_FREERTOS_HZ = 1000?

Postby MicroController » Sat May 20, 2023 10:58 pm

Another option for non-busy waiting would be to use the esp hr timer (micro-second resolution), i.e. set a timer to send your task a notification after X us, then have the task wait for that notification before continuing.

Who is online

Users browsing this forum: MSN [Bot] and 79 guests