I have a task that periodically that does some calculations and finally sends data from the calculation onto CAN. The task uses vTaskDelayUntil to be called with a fixed frequency.
The problem is, that the task has different execution times: Every for example 10 times the calculation takes significantly more time (still not as long as the fixed frequency the task is called).
The task is therefore correctly executed with a fixed frequency but the sending onto CAN in the end of an execution cycle is always delayed, when the calculcation takes longer.
My goal is that the sending is periodically.
I could resolve this problem easily when placing the vTaskDelay between the calculation and the sending onto CAN. However, this would mean that I send the data much later than it is available.
So basically I would have to separate the measurement of the execution time and the call of the vTaskDelayUntil.
Is there a simple possibility with FreeRTOS-API-Calls to solve this problem or do I have to measure the execution time myself and call vTaskDelay myself?