 Hello! Within this part we will focus on software timers within freeRTOS using CMC's OS version 2. Software timer is one of the standard component of every real-time operating system. Within freeRTOS implementation software timers allows to execute a callback at a given time of the timer period. Timer callback function execute in a context of timer service task, which is created automatically once we enable software timers within our operating system configuration. It is therefore essential that the timer callback function never attempt to block. For example, a timer callback function must not call delay functions or specify non-zero block time when accessing the queue or semaphore to not be sent into the blocked state. What is important concerning software timers is that those are not precise, intended to handle periodic actions and delay generation can be conditionally used to extend number of hardware timers in STM32. Two types of software timers are available. Periodic, which executes its callback periodically without reload functionality. To stop this type of timer, it is need to call OS timer stop function. And the second type is OnePulse, which executes its callback only once with an option of manual retrigger. And this type of software timer will be stopped automatically after first callback call. To enable software timers, we need to enable config use timers within freeerties config.h file. When timers are enabled, the scheduler creates automatically the timer service task, calling x timer create timer task function. The timer service task is used to control and monitor internally all timers that are created by the user. The timers task parameters are set through the following defines configured within freeerties config.h file. The first one is config timer task priority. So this is the priority of the timers task. And the second one is config timer task stack depth, which is the timers task stack size in words. Important message here is to set proper value of the timer service task priority to be sure that it could be executed on regular intervals to control software timers. The scheduler also creates automatically a message queue, which is used to send comments to the timer task. Like timer start, timer stop, etc. The number of elements of this queue, so the number of the messages that can be hold there are configurable through the define config timer queue length. This is as well configurable through freeerties config.h file. Let's have a closer look at configuration parameters of the software timers. All of them are available within freeerties config.h file. Just to remind you, to enable the software timers it is necessary to set one at config use parameters within this configuration file. So the first parameter is a config timer task priority. This value needs to be chosen carefully to meet the requirements of the application. We have described it already a slide ago. Then the config timer queue length. So it is the size of the queue with the comments to the timer task. And it should be estimated on the knowledge about possible senders to this queue and priority of those versus timer service task priority. Just to be sure that this queue will be not overflowed by the commands sent by the other tasks. And the last one, so the timer task stack depth. This should be estimated on the timer callback function stack requirements. So again we can use the same technique like I have proposed already when we are discussing the tasks and the stack size of the task we should assign to. More information you can find on this link present on the slide which is coming from freeerties web page and it's about configuring a real-time operating system application to use software timers. Now we will focus on software timers implementation within CMC's OS version 2. Let's have a closer look at software timers parameters which are stored within the dedicated structure, so OS timer ATTR underscore T type during creation process. This structure is defined within CMC's underscore OS2.h file. So during the timer software creation using stm32cubemix or stm32cubide or manual coding we are specifying only the software timer name. The rest of the fields are filled after the software timers creation and those are attribute bits pointer to the timer control block memory area because it contains as well something like control block and then timer control block size. So those fields are filled automatically by the function during the timer creation. Now let's have a look at main CMC's OS version 2 API functions dedicated to software timers. First it is important to remember that we need to define config use timers within freeertiesconfig.h file to use software timers API functions. To create a software timer we need to call OS timer new function. It requires 4 arguments. The first one is a pointer to callback function. Then type of the timer it can be one-shot or periodic. The third one argument is argument to timer callback function like in case of task functions usually it is not defined or defined as null and the last argument it is a timer attributes specified within OS timer ATTR underscore T structure. Usually we are defining there only the name and in case we don't want to give any name to the timer we just specifying the null here. This function returns a handler to the newly created software timer or null in case there is was a problem, usually issues with memory allocation. To start that software timer we need to call a function OS timer start. It requires 2 arguments. The first one is a handler of the timer to be started and then the second one is a timer period given in ticks usually 1ms. It returns the OS status underscore T value so 0 means successful execution and any negative value means an error. You can refer to OS status underscore T description for more details. To stop the timer we need to call the function OS timer stop. It requires only one argument the software timer handler and it returns again OS status underscore T value so 0 means successful execution and any negative value means an error. So again in case you would like to go more in details into this returned value please refer to OS status underscore T description for more details. We have covered this topic within CMC's OS API description. Here we can compare different versions of API's concerning software timers. Please have a look that within CMC's OS API's there is no distinguish between interrupt and task code execution. It is done automatically within CMC's code. What is important is that we mustn't start, stop or delete timer from the interrupt. Thank you for watching this video.