Blocked task and wake up time lapse or events?

I apologize for the beginner’s question.
I need a task that will start with a fixed time interval (for example every 100ms), but it also runs out of count if it receives a message.,
Ideally, triggering on the basis of the message should not affect the periodicity of triggering on the basis of time

How to arrange it?

Thansk you

Hi Carpenter, have you already looked at vTaskDelayUntil ?

So you require that your task wakes up every 100 ms, and also it must wake-up when a message arrives.

Is the 100 ms requirement time-critical? If so, you could create a small second task-B that handles that wakes up at fixed time interval.

If not, task-B could send a special message to task-A every 100 ms.

Or, when using a single task: you could let it block on xQueueReceive() and calculate how much it can sleep before the next 100ms interval expires.

Critical? Let me put it this way, I don’t mind a time error of + - 15% and FreeRTOS Run on 32bit ARM Cortex M4 48MHz (STM32)