Part Number: AM6442
Other Parts Discussed in Thread: SYSCONFIG
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Part Number: AM6442
Other Parts Discussed in Thread: SYSCONFIG
Additional information related to my previous question:
In my bare‑metal implementation, even though no RTOS is used, I use a semaphore. the ePWM ISR posts a semaphore, and the main loop waits on it to perform the 60 Hz work. This runs with stable timing and no missed ePWM interrupts.
Hi Miyako,
Could you let me know what is the priority of this EPWM ISR?
Best Regards,
Meet.
Hi Meet,
The EPWM ISR priority is currently set to 0 (the highest priority allowed by FreeRTOS on the R5F).
Originally it was priority 15, but I changed it to 0 as part of the debugging steps.
However, even at priority 0, the EPWM ISR is still being delayed when FreeRTOS is enabled.
Could you please tell me the recommended way to implement a periodic 60 Hz task on FreeRTOS without jitter or missed cycles?
I would like to know the best practice on AM64x R5F to achieve a stable periodic task (about 16.6666666 ms for 60Hz) with minimal latency and no drift.
Best regards,
Miyako
I would like to know the best practice on AM64x R5F to achieve a stable periodic task (about 16.6666666 ms for 60Hz) with minimal latency and no drift.
vTaskDelayUntil() can be used for this: https://www.freertos.org/Documentation/02-Kernel/04-API-references/02-Task-control/02-vTaskDelayUntil
However, even at priority 0, the EPWM ISR is still being delayed when FreeRTOS is enabled.
Setting it to the priority 0 is correct but is your ISR using any of the FreeRTOS API? The thing is configMAX_SYSCALL_INTERRUPT_PRIORITY is set to 4 for R5F's freertos kernel, so if any ISR having priority higher than this uses the FreeRTOS API then it might cause some undefined behaviour, you can set the priority as 4 if this ISR is using FreeRTOS APIs. Please refer to this: https://www.freertos.org/Documentation/02-Kernel/03-Supported-devices/02-Customization#configkernel_interrupt_priority-configmax_syscall_interrupt_priority-and-configmax_api_call_interrupt_priority
Hi Meet,
Thank you for your explanation.
Regarding the 60 Hz periodic task:
I understand that vTaskDelayUntil() is the recommended FreeRTOS method, but due to the 1 ms tick resolution and interrupt latency on the AM64x R5F, it seems difficult to achieve a perfectly stable 16.666 ms period.
I also tested the EPWM ISR at priority 0 and at several other priorities, but the ISR still shows delay and jitter whenever FreeRTOS is running.
From other E2E threads, it appears that EPWM interrupts can still experience latency on the R5F due to interrupt pipeline behavior and system activity.
So my questions are:
1. Is it realistically possible to achieve a jitter‑free 60 Hz loop on the R5F using FreeRTOS task scheduling?
2. Or is the recommended approach to use EPWM ISR and notify a task for accurate timing instead of relying on task delays? (using semaphore)
3. Is EPWM ISR latency generally expected when FreeRTOS is enabled on the R5F?
Any guidance on the best practice for low‑jitter periodic control loops on AM64x R5F would be greatly appreciated.
Best regards,
Miyako
Hi Miyako,
1. Is it realistically possible to achieve a jitter‑free 60 Hz loop on the R5F using FreeRTOS task scheduling?
Using only task scheduling and vTaskDelay function it is not possible. this is due to the fact that FreeRTOS tick has a resolution of 1ms tick, so achieving 16.66ms precise period wouldn't be possible with this.
2. Or is the recommended approach to use EPWM ISR and notify a task for accurate timing instead of relying on task delays? (using semaphore)
Yes, this would be the recommended approach to get the accurate 60Hz task.
Is EPWM ISR latency generally expected when FreeRTOS is enabled on the R5F?
Yes, some latency is expected due to interrupt pipelines, context saving and other possible scenarios like FreeRTOS critical section, but this should be minimal, could you let me know how much delay/jitter you are currently observing.
If you are observing large delays then that could be coming from the critical sections of your FreeRTOS kernel code that masks interrupts above priority configMAX_SYSCALL_INTERRUPT_PRIORITY(4). And you can't call any FreeRTOS APIs from ISRs having priority below 4, so you can't call SemaphoreP_post if your ISR has 0-3 priority, if you are doing so then it can lead to Kernel data corruption or task scheduler corruption leading to an undefined behavior.
So yes, you could observe some delays if you are using ISR with priority above 4 and if that latency is not acceptable for you, then you can continue with the baremetal application. It would be good to know how much latency you are observing currently (should be a few us).
Best Regards,
Meet.