RTOS time management articles - soft timer xTimer handles one-time timing events

RTOS time management articles - soft timer xTimer handles one-time timing events

overview

The previous section described various strategies for delay in RTOS. In actual development requirements, it is also very common to realize the need to trigger an action at regular intervals.

As mentioned above , the hardware timer resources of the device are limited, and the timer component that can be implemented in software is provided in the RTOS, which can realize timing tasks with less precision.

The software timer provided by FreeRTOS supports the one-shot mode and the periodic mode . The timing events of the one-shot mode and the periodic mode will call the callback function of the software timer later, and the user can add the project code to be executed in the callback function.

insert image description here

A single timed event means that after a specified period of time, the execution of a piece of code is only triggered once. As shown in the figure above, Timer1 with a period of 3, if it is a one-shot soft timer, will execute a callback at t4 after it starts at t1.

Timing events in periodic mode: trigger the execution of a piece of code every interval. As shown in the figure above, Timer1 with a period of 3, if it is a periodic soft timer, will be called back at t4, t7, and t11 after it is started at t1, until the timer is stopped or destroyed.

The operating mechanism of the software timer xTimer

FreeRTOS through a TimerTask task (also called guardian task Daemon&#x

Guess you like

Origin blog.csdn.net/wangyx1234/article/details/128377450