 Hello, and within this part, we will have a closer look at event flags in practice. Now it is time to test event flags in practice. We can reuse any of previous projects from this session. In this part, we would need one interrupt source. When using nuclear board, we can use a blue button, which is connected to PC-13. Then we will start with stn-32-cube-mix or stn-32-cube-ide configuration. And then, within three RTS configuration, in config parameters, please enable software timers and set timer priority to OS priority normal level. Then within task and cues tab, please create three tasks, task1 with start task1 function, task2 with start task2 function, and task3 with start task3 function. All of them should have the same priority level, like OS priority normal, like in our timer task. And the stack size set to 256. Roles of those components will be the following. Task1 will wait for an external interrupt and task2 action occurrences, or they're not important, by waiting for 51 hexadecimal within eventgroup1. Task2 will set 1 within eventgroup1, task3 will be used later, and blue button interrupt will cause settings 50 hexadecimal within eventgroup1. Under those operations, please generate the code and open main.c file. As you notice, there is no event flux generation option within current versions of stn-32-cube-mix nor stn-32-cube-ide. Event flux objects should be declared and create manually by the developer. Within main.c file, in user code begin pv sections or private variables, please declare eventgroup1, it is OS event flux ID underscore t type. Then within main function, after hardware initialization, within initialization of OS components, please initialize create eventgroup1 by calling OS event flux neo function with null argument. You can see it on the screen. Then we can use our newly created event flux within start task1 function, which is an entry function of task1. With its endless loop, please insert the function which would wait for eventgroup1 object to be equal to 51 hexadecimal. To do this, we will use OS event flux weight function with the following arguments. The first one would be eventgroup1 handler, then the second one would be the mask we are waiting for. In our case, it will be 51 hexadecimal. The third argument would be, let's say, the selected options. In our case, we would like to wait for the complete set of masks. Then the last fourth argument is a timeout. In our case, we'll wait till the mask will be set, so we will use OS weight forever. After the eventgroup1 will be set to 51 hexadecimal, task1 will perform its action by sending one over SWO interface. Now let's add some code to other components which would be responsible for eventgroups mask set. With an start task2 function, which is an entry function for task2, please add OS event flux set function to set1 within mask of eventgroup1. In fact, it will be ORT with a already existing value. Then, please send 2 over SWO interface. At the end, task2 will be sent to blocked state for 3 seconds using OS delay function. When an external interrupt procedure, please set mask for eventgroup1 to 50 hexadecimal. Again it will be ORT with a already existing value. Then within this callback, please send an exclamation mark over SWO interface. After those operations, please build a project, start the back session, open SWV-ITM console and run the application. As a result, we should see one displayed on the console, once on each 3 seconds, it would be a task2 action and the button press, which would be an external interrupt action. Let's have a look at the result. The beginning only task2 has been executed once per 3 seconds, so we can see 2 digits on the console. Then in this time, task1 is waiting for a combination of 2 fluxes, so 50 hexadecimal coming from the interrupt and 1 coming from our task2. So once we press the blue button, our task1 will be unblocked, so it will be moved from blocked state to run state. It will execute its action, so it's sending 1 over SWO, this is one we can see, 1 just after the exclamation mark coming from the interrupt and then it will enter into the blocked state again as it will, let's say this flux will be cleared on exit of the wait function and we need to wait for the next combination of task2 and interrupt flux set. This is why on the screen we can see after exclamation mark 1, then there are let's say series of 2 digits once again and just after next exclamation mark we can see again a single occurrence of 1, which means that the task1 has been unblocked by the combination of 2 fluxes coming from task2 and coming from the interrupt. We can unblock more the tasks on the same event flux set. To test it, we will involve our task3 into the game. Let's modify start task3 function, so it will wait for 51 hexadecimal mask with an event group 1 as well. Once it will be successful, it will send 3 over SWO interface using task underscore function. We will keep rest of the code not changed. Please compile the code, start debug session, open SWVITME console and run the application. As a result we should see that both task1 and task3 will be invoked each 3 seconds if there would be a button press. And here is an illustration of the final effect. At the beginning only task2 has been executed once per 3 seconds. Task1 and task3 are waiting being in a blocked state. They are waiting for a combination of flux 51 hexadecimal which could be delivered by task2, it's 1 and interrupt it's 50 hexadecimal. Once we press the button, the one flag within the weighted combination has been set and it will unblock task1 and task3 and both will be moved from blocked state to run state which is visible for us as a display on single wire interface console. We can see 3 and 1 display just after an exclamation mark. Then both tasks will be moved into the blocked state again as the flux has been clear on exit of the weight function. And both will wait for the next combination of task2 and interrupt flux set. So as we can see on the screen there is a string of 2, 2 then if there is exclamation mark, so the button press, there is let's say the combination of flux delivered, so 51 hexadecimal which is unblocking 2 tasks, task3 and task1. This is why we can see 3 and 1, 1 by 1 after the exclamation mark. And then there is 2 again. Thank you for watching this video.