I’m new to FreeRTOS. I’m starting with simple demos, one of them showing how to send and receive messages between tasks. The sender sends a number of LED blinks to do and waits a hard coded multiple value of ms, depending on the number of blinks to do, before sending another message.
This naturally begs for a question about : is there an approach in FreeRTOS to estimate the time it takes for a task to execute ? The basic would be to generate assembler code from the C code then evaluate the number of cycles needed although I’m wondering if FreeRTOS provides a custom approach to egt a good idea of the time required by a task.
Perhaps a better idea is rather than trying to wait for a certain amount of time, let the blinking task send back a message to say it is done, and can take a new command.
Or, put the commands in a queue, and processes them, and if the queue is full, the sender has to wait.
Please refer to xTaskGetTickCount() to see if that can help you estimate easily. Note that the unit of it is tick, you have to convert that back to time unit based on your configTICK_RATE_HZ configuration.
As @richard-damon already pointed, rather than attempting to calculate execution time (which can vary due to other high-priority tasks or interrupts), a more robust solution would be to implement explicit acknowledgment from the receiver once it completes message processing.