 Hello, the purpose of this lab is to play a bit with tasks or threads. This is the name of the WUVN CMC's OS version 2 layer. So I would create a new project with an stm32cube IDE. I will go into file, new, stm32 project. After a while I should see the product selector. Okay, and we will select our microcontroller, so it's L476RNG. This is our microcontroller, I press next. And the project name, so I would use one underscore tasks. And I press finish. So now I expect to see the pinout of my microcontroller. Okay and the first thing I will do is a configuration of the debug interface. So I go to system core within this group. I would select within debug trace asynchronous swo, just to have three lines. So this classical swd and our single wire output which is used for this single wire tracing which we are using to communicate between our tasks and the interrupts and we are displaying messages from those elements on the console. Okay, so this is the debug interface. Then I'm changing the time-based source from cistic to timer 6 as we discussed, to have different timer for operating system and for HAL library. So this is next point. The third point would be enabling the free R2S. We will not use an led and nor a button in this exercise, so I would not enable them. Within free R2S I would select the interface CMC's V2, so version 2 which is much more powerful, let me say this way than previous version of CMC's V1. It contains much more functionality and better connection to free R2S API. I will not modify anything the moment within the config parameters, so we are using total heap size 3 kilobytes because it's in byte. Then memory management scheme the most popular heap 4, there would be no change and we will include parameters. We need to add the VTaskDelay, so the delay functions. Those functions are called via CMC's OS layer, we will call OSDelay which is in fact calling this one. This function is sending our active task to so-called blocked state and is allowing other, giving let's say the CPU time to other tasks. As we can see this is enabled, so there is no need to do any additional modification here. Let's go to the tasks and queue stop. Then we will change our default task into task yet task1, so I will double click on it and then I change the default task name into task1, priority normal, stack size 128 words because it's given in the words should be enough in this exercise. Then entry function, I would change it to start task1, I would not use any parameters, allocation it will be dynamic and count generation option we will select the default not weak, so we're not overrided in the count. What is important here is to have a look always on this priority level, this OS priority normal, I'm describing this more in details within CMC's OS API section within this training. The important point is that this let's say type def, this value have some numerical value. When using CMC's OS we've got a gap between priority idle and priority low. The gap is between numerical number one and eight. So any value between one and eight if we are using only numerical ones could cause some issues within the count. So please have a look what is behind this name, what a number and be aware of it because the wrong priority is one of the most common issue within the operating system application. Okay, so it would be task1, I press okay and I would add one more task so I would just click add and I'm just resizing task2, priority low, no. We will select priority normal, okay, and we will name this function start task2, that's it. So no more actions are let's say needed from our site on this exercise so I would generate the code. I can use this icon and we can see our new main.c file, you can see a lot of it's a user code section so where we need to put our code. If you go below we can see the places where our new tasks are declared. Both of them have their own handlers, this is OS thread id underscore t type. For both handlers we can see the attributes as well. So we are specifying only the name, priority and the stack size within attributes. Additionally there is as well the pointer to task control block and stack area of the task which would be filled during the creation of the object. What is important here is please have a look that stack size we defined in words, this is why here it is multiplied by four. If we go below within main function we can see the hardware initialization so how you need the system clock config. We have not touched this so we are using standard default 4 megahertz with an L4 family. Then there is initialization of the GPIOs. There was no modification from our site so there should be not much change here. We only selected three lines for the SWO. Then there is initialization of the scheduler which is in fact a location of memory for its heap. And then below we can see the creation of the components in our case both tasks. So task one and task two. As you can see we are using OSTRED new function. First argument is the function which would be called within this task execution time. Then we've got the argument which we are not using so it's zero and the attributes which we specified before. After this there is a start of the scheduler. Then we are just executing tasks one by one. So if we go below we can see both tasks function body bodies. So you can see that both tasks are the moment almost empty. We can see nothing within the initialization part so before the endless loop and then within endless loop we've got only OS delay with argument one. Which means that the task would be sent to one millisecond into the blocked state and then it will come to ready state again. So now this is the time to perform some action on our side. So let's start with some coding. So I would use here the function which would be called task underscore action. And within this function I would like to send one character. It would be the number of the task and then I would send the task for one second to blocked state. The same I would do within task two. So task action two and sending the task to block state for one second. For those of you who have followed the first exercise where we created the template the task action would be not a surprise but for the rest of you who started with this part I would just present an example where you can define your own task action. In my case I would use the function the following way. So it would be task action accepting character and then it would be a message one let's say character sign. Then I would use itm interface and we will send the one character so one or two and then just to be sure that we'll have the same the data in the new line I would put as well the new line sign at the end. Okay just one more thing to be done it's a declaration of this function within the proper section which is the private function prototype here. So like this and we can check whether our code is working. So we've got both tasks. Task one will send one and then it will go for one second into the block state and task two will send two and go to block state for one second. Once both tasks will be in the block state the only task which could be executed would be idle task. So it will be quite invisible for us so let's try to build it. So I build the code in the meantime as you can see on the on the camera my board is already connected so if it is not the case on your side please connect it now. So this is it no errors no warning. Now we can go to the debug so I press the bug icon. I will just check whether the swo interface is enabled so debugger swd connect under reset swo v it's not enabled so when I enable this I will select four megahertz which is our clock and then I would apply and okay so now I will switch to the debug the console let me say this way just to display the swd itm console I already have it here in case you will not have it you can use the quick access and then check swv and you can select itm data console over here if it's not not yet done on your side and once you've got this console you can configure it by this icon and it's important to enable this port this one bit this is our swo so I press okay and I need to start tracing so I press this icon this button and I can start my application and as you can see once per second I can see both tasks sending the data on the console so it is like like expected I can let's say suspend execution or I can just terminate the debug session and come back to my cc++ perspective so I will do so okay that's all for this part in next next part we will modify this example and perform some more actions so thank you for watching this video