ESP32 I2C send 512 bytes asynchronously

Internet says around 1200 processor ticks per task switch (on average). On 240Mhz it gives 0,000005 sec. Nothing

Hello,

So, around 5µs per task switch...

And I have to issue steps every 5µs...

And if I have 2 tasks running, it means that there is 5µs to switch away from my task, and another 5µs to switch back to my task... not taking into account the execution time of the other task... so, at least twice longer than I want....

Hence, this is not the solution for my use case :frowning:

Some CPU have HW that can send bit streams out through one or more GPIO pins...
You basically give it a pointer to a memory area and it will send all the bits at a given speed.
I could use this to handle my bits out in HW and reduce my load, and especially reduce my high time dependency...

Does anyone know if there is such facilities on the ESP32?

Cyrille

Well ESP32 has a peripherial called RMT. It can send bit sequences in background. Not sure if it can be solution for you or not. It does it in hardware and with resolution down to 0.0125 uS. I played with RMT in blocking mode but as far I know it could be done in async mode too.

For those interested: i made an experiment on my ESP32 Dev Board @ 240Mhz. Task switch time as a function of number of tasks.

Experiment #2, 20 tasks at once, measuring..done.
20 tasks, switch time is [5.27..5.27] microseconds (CPU @ 240 MHz)

Experiment #3, 30 tasks at once, measuring..done.
30 tasks, switch time is [5.27..6.46] microseconds (CPU @ 240 MHz)

Experiment #4, 40 tasks at once, measuring..done.
40 tasks, switch time is [4.93..6.09] microseconds (CPU @ 240 MHz)

Experiment #5, 50 tasks at once, measuring..done.
50 tasks, switch time is [4.93..7.61] microseconds (CPU @ 240 MHz)

Experiment #6, 100 tasks at once, measuring..done.
100 tasks, switch time is [4.93..8.03] microseconds (CPU @ 240 MHz)```

Crashed with 150 tasks

Hello,

So, we are talking around 1200 cycles for a task switch (is this switch from T1 to T2, or T1 to T2 and back to T1)?

How many tasks are you guy usually running!

I mean, I usually try to limit tasks to the bare minimum... my most complex program using FreeRtos is 4 tasks (we are talking about a high end graphical calculator)...

Cyrille

correct.

I noticed no switch time change between task until I went to 20 tasks. 1..20 tasks have exctly same switch time: 5.25us. When more than 20 task started then there are "waves" started to happen: number of task get switched faster than another group. When I went to 100 tasks, the task switch time was slowly oscillating between the same 1200 cycles and a higher value (8..9us or so). So it is 1200 cycles + FreeRTOS scheduler overhead.