I have a case where I need to set the delay . The delay varies between 5-15 seconds . I am using STM32 . below is my code . I want to modify these variables when these delays expire . But I do not wan to block the task. How do I achieve this in FreeRTOS.
When you create a timer, you connect a subroutine that will be called when the timer expires to that timer. That timer can be used and reused as needed. You can change the timeout period for the timer (and make it auto-restart for periodic activation if desired).
In your case you could either create 3 separate timers, each that calls a function that sets the appropriate variable, or you could create 1 timer that calls a function that keeps track of what “step” it is on, setting the appropriate variable for that step, and then restarting the timer for when the next step should occur. Then when the condition occurs that you want to trigger them your start the timer(s) and things will happen when they expire.
Adding to what @richard-damon mentioned, To do it in a single function you can use auto-reload timers which gets periodic callback execution and set the auto reload timer period according to your use case which seems to be 5seconds here.