 Let's start with some preparation to hands-on parts. This part can be adapted to the board which you are using based on STM32 device. Complete session is MCU or board agnostic. To perform hands-on parts within this session, we would need the following hardware components. PC with pre-installed software listed below, Nucleo L476RG board or any other STM32-based one having at least one LED and one button to have basic user interface. Mini USB cable to connect your board to PC. Optionally, if you are interested in low power modes, it is recommended to have XNucleo LPM01A board, Micro USB cable to connect this board to PC, Two female cables for standard gold pins to make the connection between XNucleo and Nucleo boards. Concerning software components, we need to install on our PC. STM32-Cube IDE in version 1.2.1 or more recent one. Most of the, let's say, exercises, the templates are done in 1.4.1, in fact. And within this cube IDE, you need to install STM32-L4-Cube library in version 1.15 or more recent one. Instead of STM32-Cube IDE, you can use STM32-Cube Amix with installed the same cube library and the tool chain, which is supported by Cube Amix, for example IRK or SW for STM32. In case you would like to perform some power measurement exercises, you will need as well STM32-Cube monitor power application. Our goal is to prepare a simple project for a selected MCU, which can be used within all of our hands-on parts. As an example, we will use STM32-L476-RGTX, which is present on Nucleo-L476-RG board. Within our simple project, we need to configure one pin as a user interface output. It will be pin 5 on port A. There is a green LED connected there. We'll configure it as output push-pull and we'll put LED underscore green label on it. Then we need one pin as user interface input. It will be pin 13 on port C. There is a blue button connected to it. We will configure this pin as XT13 and label it blue underscore button. Next, we will need a debug interface, so in our case single wire debug SWD, with asynchronous trace to perform the debug of our MCU. Then we would need to change a time-base timer from default SysTik to Timer 6, as SysTik will be locked by FreeRTOS and cannot be shared with other hardware components. From middlewares, we will select FreeRTOS Inversion CMC's V2. Optionally, you can configure USART2 on PA2 and PA3 pins in case you would like to redirect printf to this interface. USART2 is connected to onboard STA link and is visible via virtual COM port on your PC. To simplify the configuration, we'll keep default clock configuration for megahertz-based MSI oscillator. After this configuration, we will generate the code using hardware abstraction layer, HAL library, and open it in selected tool chain for code processing. In our case, it will be always STM32QP IDE. In this presentation, we will use STM32QP IDE for configuration code processing and debug operations. Within all hands-on sessions, we will use either Cubemix or Cubemix IDE to perform this. You can choose which one is more suitable for you. The main interface is very similar. Then the code processing and debugging can be done in other tool chain supported by Cubemix. From main configuration window of STM32QP IDE or Cubemix, please configure. PA5 has GPIO output and it set its label to LED underscore green, PC13 has GPIO underscore XT13 and set its label to blue underscore button. From CIS category, please select trace asynchronous SW within debug option and select timer 6 as the timer source. From middleware category, please select free R2S with interface CMC's V2. We can verify our GPIO configuration within GPIO tab. We will not use any internal pull-up nor pull-downs. Important point here is to select proper GPIO mode for PC13 as external interrupt mode with rising edge trigger detection. It is important to enable interrupt for XTI line 13 as it is not done automatically. Please have a look at new column within NVIC configuration window, uses free R2S functions and enable it in case you would like to use the interrupt with cooperation of operating system. In some versions of STM32QP MX and CUBE IDE there is no uses free R2S function column and you'll need to adjust manually the preemption priority of your interrupts in case you would like to call operating system functions from them. Proper value can be found within free R2S configuration config parameter tab in library max syscall interrupt priority, usually it is set to 5. We'll keep default clock configuration for megahertz coming from MSI os later so there is no need to change anything within clock configuration unless it is directly specified within handsome part. We have finished basic peripheral configuration. Let's generate the code for selected toolchain if you are using STM32QP MX or for CUBE IDE. First we need to specify the location and name of our project. In case of STM32QP IDE it has been done at the beginning of project creation. Project from this exercise is stored as well within the solutions solution projects and it's named nucleo-l476rg underscore template .zip file. You can import it you can import it within your current workspace. After this please click generate code when STM32QP MX and once you're using STM32QP IDE please go to project generate code or just press alt plus key or just save the changes by pressing ctrl s. Let's have a look at generated code. We will start from main.cfi. We can use ctrl space to find a proper function or argument we would like to use. Just start typing and at any moment please ctrl space to display a list of possible components to be selected. Be careful and use only user code sections for your code. Otherwise your code will be removed during next code generation. In our example we will need to look for start the default task function body. This is a default task generated once we selected free artist. Within this function body we need to add some code within its endless loop to toggle LED green each 500 milliseconds. To do this we need to use hull underscore GPIO underscore toggle pin function with first argument LED underscore green underscore GPIO underscore port. You can just insert LED underscore and press ctrl space to find the proper value. And second argument is LED underscore green underscore pin. Let green is our label set for PA5 pin during peripheral's configuration. Assignment of the labels of the pins is done within main.h file. This is our final code. The result should be green LED toggle each half a second. Now we can build the code and start a debug session. This is the time where we need to connect our boards to PC. Within stm32qpide and all Eclipse-based fullchains we can build the code using hammer icon and then start a debug session using bug icon. In case we would be asked how we would like to debug the code, please select stm32mcocc++ application and press OK. When running debug after successful compilation there is no need to configure anything for debug in this project. Just connect target board to stlink and press OK. It may happen that a stlink firmware on your board is not up to date. In this case a stlink upgrade tool will be run automatically. Please open an update mode, select change type, checkbox if present and press upgrade button. After this operation you can start the debug session again. At first run of the project there would be a warning message displayed concerning different perspective view. Switch from cc++ perspective to debug one. I would recommend to select remember my decision checkbox and press switch. Once we are in debug mode there will be a different set of windows present, so called debug perspective. Under the menu we can see new set of buttons to control the debug process. Most important ones at the beginning are run, pause and terminate. Run triggers the code execution and continues its execution after the pause or breakpoint. Pause stops code execution to check the registers or variables. It is possible to continue code execution by pressing run button again. Terminate stops code execution and terminates the debug session with return to cc++ perspective for further code processing. It is not possible to continue code execution after we terminate it. We need to start the debug session again. Here we can see the most important windows within debug perspective, which are visible during debug session. On the left there is a project debug explorer. In the middle we can see our source code, where we can put breakpoints by double click on the left button mouse next to the line number. On the right there is a window with set of tabs, which allows us to display registry contents, so called SFRs, watch variables or expressions. Let's come back to our application. Press run within debug session and check whether our green LED is toggling. Now we can prepare our template to be as universal as possible. Within next parts we would need to perform some actions by particular tasks. There could be up to four of them within one application and it would be good to distinguish them somehow. I propose to implement a universal task underscore action function, which would accept only one argument, task which is calling, and would perform some action as a result. The easiest way is to use printf function inside, but please be careful as this function can be very heavy in terms of RAM and flash usage and its execution time. The best and simplest way is to use existing LEDs. Unfortunately, we have only one on the nuclear board. An alternative can be usage of single wire output SWO to send simple text messages and display them with an ITM terminal window with an STM32QPIDE. We could use USART interface and standard terminal instead. Here we can see some examples of task action function. LED toggling is the simplest method. Unfortunately, on nuclear board we've got only single LED, so it would be difficult to use it as user interface within multi-tasking system. Single wire viewer is an interesting solution, which requires debug interface to monitor this line. It is fast as its synchronous with the system clock and it's using one line within ITM interface present on Cortex M3, M4 and M7 devices. We do not have this solution with an STM32F0R0 nor G0 lines. Using UART is a very good choice as well, especially with nuclear boards where USART2 is connected to S-Tilling that is visible as virtual comport on PC. We could use it as a terminal application to monitor information coming from the MCU. In our training we'll use the middle one, so based on single wire output SWO additional pin available within SWD interface. Please add your code within user code begin4 section. Function will accept only one 8-bit argument and will return nothing. Inside we will use ITM underscore send char function to send one character passed by argument and additionally we will add a sign of new line. We need to add a declaration of task underscore action function within user code begin private function prototype section. To use it within task we need just to call it with single character as an only argument like on below example. After this we can compile the code using hammer icon. After the successful completion we need to configure debug session to use serial wire output. Before this we need to configure it. Please select debug configurations and select Cortex M option. Within debug configuration window please select debugger tab. Then select SWD interface. Set reset behavior to connect under reset. Enable single wire viewer SWV. Set core clock to 4 MHz which is used in our examples. Enable live expressions. After all of those steps please click apply to save configuration and click on debug to start the debug session. Within debug session we need to display ITM console to display data passed by ITM send char functions. To do this please insert SWV into search window on top right corner of the cube IDE. Then please select SWV ITM data console from the list. In the next step within SWV ITM data console window please press on plus icon to add port and select port zero. Then press OK. Within port zero window please press configure trace icon and enable port zero from ITM stimulus ports. In case you would like to monitor any variable you can add them within up to four comparators. Then press OK. After trace configuration please start trace. Now we can start the code and we can observe the data sent to console by function ITM underscore send char. Just few words about project management within STM32 cube IDE and similar Eclipse based tool chains. To save time needed for new project creations we may use this exercise during next hands-on parts. In case you would like to store each exercise as a separate project folder or hive please use file export option from the menu and store an example in dedicated zip file like an example on the slide. You can reuse stored examples by using import option from file menu within any workspace later on. Thank you for watching this video and now we can start our adventure with free RTOS.