My blinking LED activity task is operated using a 50 ms FreeRTOS timer. I wonder if I could improve the overall system performance by moving to a hardware timer. Is that reasonable?
(I’d use the ULP risc-v, but my C6 has none 🥲)
ESP Timer vs. FreeRTOS timer
-
- Posts: 1706
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: ESP Timer vs. FreeRTOS timer
No.Is that reasonable?
50ms is an eternity compared to the overhead of a timer callback. Even if you could shave off 5 micro-seconds per timer event, that'd reduce CPU load by 0.01%.
That said, the FreeRTOS timer does callbacks from the IDLE task, and the ESP HR timer uses a dedicated task to do the same thing. You can however set the ESP HR timer to run callbacks directly from the timer's ISR (or use a dedicated hardware timer with your own ISR), which would a) reduce jitter due to tasks' priority-based scheduling and b) mitigate the overhead of task switching to and from the timer task. Point a) may be valid if you require low jitter, point b) becomes meaningless when talking about milli-seconds, or when using the IDLE task to execute callbacks as FreeRTOS does.
-
- Posts: 168
- Joined: Sun May 22, 2022 2:42 pm
Re: ESP Timer vs. FreeRTOS timer
I don't know why, but it never occurred to me that I can (ab-)use PWM for blinking, can't I? That would reduce the system load.
-
- Posts: 1706
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: ESP Timer vs. FreeRTOS timer
Sure, PWM is blinking
You'll just have to verify if the LEDC hardware supports that low frequency of 10 or 20Hz.
As to the performance: Blinking an LED at some 10-20Hz in software still produces an immeasurably low CPU load. However, if you now have a dedicated task for just the blinking, doing away with that extra task can free up some 3-4kb of RAM.
You'll just have to verify if the LEDC hardware supports that low frequency of 10 or 20Hz.
As to the performance: Blinking an LED at some 10-20Hz in software still produces an immeasurably low CPU load. However, if you now have a dedicated task for just the blinking, doing away with that extra task can free up some 3-4kb of RAM.
Who is online
Users browsing this forum: No registered users and 81 guests