 on our STM32Q IDE by Ziggs training session. In this video, we will do the first hands-on. The objective of this lab is to create the project using STM32Q BMX and HALA libraries, which would allow us to toggle RIN LED, which is connected to PA5 pin on our nuclear board. Here you can see the part of the schematic of nuclear board, which we are using in our exercise. Our LED is called LD4, and this green LED, which is connected to PA5 pin for what you can see on the screen. Let's open the CUBE IDE application. The first thing we need to do after run of this application is to select the location of the workspace. I would select the different name just to start everything from scratch. In my case, it will be C, then underscore work, and subfolder CUBE IDE, but with number three. I launch the application and the workspace is empty. There was no project inside the workspace. It doesn't contain any project. We can see this information center on the screen, and we can start a new STM32 project. So I select this icon. So the first thing is to select the micro-light to use for our project. Take some time. So this is the target selection window. We have three options here. Either we will select the particular part number, MCU-MPU, or we will select one of the ST boards, which is equipped with STM32 devices, or we will select across a selector, selecting some ST competitors, and I try to run similar project on STM32 devices. We'll select the MCU-MPU selector, just to do everything really from scratch. And we need to select our micro. In our case, it is STM32-G071-RBT6, part of it, because STM32 is existing in all of the products. I'm starting from this G071-RB. I can see one choice, RB. I selecting this part number. So we see two of them. We are selecting LQFP64 package, because this one is located on our nuclear part. Once I highlighted this number, I click Next on the bottom of the page. And the next step is to specify the project name you would like to create. Here you can see the default location of the workspace, and within this workspace, we'll have as well the location of the projects. I would call my project as a G0 underscore LED, and I have some options to be selected. By default, it will be C project, the binary type. It will be executable, and the project type, it will be STM32 cube-based. We can select as well C++, we can select the static library, which can be reused in other projects, and we can select as well the project type SMT, but in this case, we will have just an empty skeleton of the application, and we need to define our set of the registers, register map by ourselves. In our next videos, you will see the project generation using this empty project type. So you can follow this part as well. Let's continue with the project setup using STM32 cube. Let's press Next. On this window, we can see the micro, we just selected the version of the library we will use. So in our case, it will be cube for G0, version 1.2.0, and the location of this library. So in my case, it is C underscore work and subfolder underscore cubemix. Below, you see as well the link to the configuration window, where you can configure the repository location for your libraries. In this window, you have an option to select the code generator options. So either you will copy all the necessary library files to the location of your project, or you will use it as a reference to the original files. We will use the default settings. Copy only the necessary library files. Okay, let's press Finish. As a result, we can see some information window about the perspective change. Within Eclipse environment, you can have a set of so-called perspectives. So this is the configuration of the window set, which is present on the screen. Within STM32Cube IDE, we've got at least three main perspectives. The first one is so-called CC++, which is used to edit the code, perform the compilation of the code. The second one is so-called STM32Cubeemix or device configuration perspective. And the third one is a debug perspective, which is used to debug the application. So I would just click remember my decision and yes. So now it is starting device configuration, part of IDE software. In case you have not downloaded the STM32Cube library, it will be done automatically, as you can see on my screen. So the application will connect to the repository, the webpage, the proper cube library will be downloaded as a zip file and then unzipped in the folder we just specified two steps before. We need to wait a bit to download and unzip the complete pack for G0 family and we will continue. When it's done, we can see the screen similar to mine. The central point we can see selected microcontroller all of its pins, yellow pins are related to the power supply, unused pins free to use are marked as gray, as you can see on the screen. The other colors means that the pins already assigned as a power pin or some reference pin, as you can see on the screen. So the first thing we need to do to create our LED toggling application is to select and configure the debug pins. So I would go to the system core. I would select from sys-per-frl serial wire. Serial wire, it's in fact SWD serial wire debug interface, which is common to all STM32 in general Cortex-M devices. So once we select this interface, we can see that two pins, PA-13 and PA-14 are already dedicated to this system peripheral SWD IO, SWCLK, so the debug interface pins. So this is the first point. The second point, we need to select the pin we would like to control. This package is not that big. So it's quite easy to detect the PA-5, it is over there. But if you will have bigger package, some PGA, where there are a lot of pins, very nice way to detect the pin is to use the search field on the bottom of the screen. I can type here the pin I'm looking for. So PA, now you see all PA pins are highlighted. I'm selecting PA-5. So it is over here. I'm clicking left button on mouse and selecting GPIO output. Okay, now pin is selected by me. This is why I can see this pin over it. And it is green, so it is selected. It is a some role assigned to it. Now I can assign as well the label to this pin to have easier access from my code. To this purpose, I'm clicking right button on mouse over the pin. And so I'm selecting enter user label. I would propose here LED underscore green and press enter. Okay, we've got debug pins, so we've got our LED, green LED pin. We do not need anything else for the moment from this perspective. Let's have a look on the clock configuration. So this is the second tab clock configuration is over here, I just click it. And I can see the clock scheme of selected STM32701 microcontroller. By default, all STM32 devices are clocked by the internal oscillators. In this case, it is HSI, so high-speed internal RC. Its frequency is 16 megahertz. So this is the default clock source for the system, as you can see. We are not using any PLL or external components. This is just to simplify the application and make it easy to start. We will not change anything on this step. We will play with the clock configuration during our next hands-ons. Okay, let's go to the project manager to generate the code. As you can see from the project manager, we've got already specified the project name, project location. We've got as well the tool chain folder location and tool chain IDE. As you can see, there is no selection over here in the tool chain IDE. As we are running STM32 cube IDE, which is the combination of existing STM32 cube MX and CC++ environment, there is no option to change the tool chain. To generate the code, it is enough just to save the current project. As you can see here on the top, we've got the small star, which means that the file has been edited and it must be saved. So I just press Ctrl S and I've got the information window, whether I would like to generate the code. I just press yes and the code is generated. You can see it on the left side of the screen. So here on the left side, you can see the project explorer for our project, zero underscore one. You can see some main components here, like drivers, source, startup, include, then IOC file, which is the device configuration file we just finished and the linker file for the flash memory. Now we will open the main.c file, which is the main source file for our application. What we can see here is a template generated by our configuration tool. Within this, we can see the main function. We can see some set of configuration functions which are using the library. So the next step we need to do is to perform this LED toggle. To control this LED, we will go to the while one loop over here. Please remember to keep your code within this user code, begin user code and spaces. Otherwise, if you put it somewhere else, like in this line, which are just between those areas, your code would be erased during regeneration of the code or any modification done within the device configuration. Okay, so let's start with the coding. So the first thing we need to do is to find some function which would control our LED. As you remember, we are using the HAL libraries. Let me remind you, it's hardware abstraction layer. And all of the functions which are within HAL libraries begin with the prefix HAL. So HAL underscore. Then if you would like to control some peripheral, we need to put its name. To control LED, we need to control GPIO where we've got the LED connected. So the next point would be GPIO underscore. And if we don't know which function could be used here, we can use control space. Control space is looking within the library and it's displaying all the functions which are starting with HAL underscore GPIO underscore. It is very nice feature implemented in Eclipse environment. It's speeding up the coding process. So from the list of the available functions, I would select this HAL GPIO toggle pin. And we've got two arguments here. One is the port and the second one is the pin. I can use here the name of the port, so GPIO A and then GPIO pin five. But please remember that we have used label for the pin. It is LED underscore green. And if we use label, it should be visible as well for the coding. So let's use this label. LED underscore green, control space. And I can see two defines. The first one is port, the second one is pin. I would select the port. And on the second position, I would do the same. LED, control space, LED green pin. The first thing is done, LED toggling. The result of the function would be toggling of a PI five pin where our green LED is connected. To make it visible, we need to put some delay after. How to find the delay? Within the HAL libraries, we've got as well the dedicated function to make a delay. Let's try to find it. HAL underscore delay. As an argument, we need to put a delay value in milliseconds. I would put 500, so it will be half a second. And that's it. The code is done. Now we need to build it. To build the code for this project, we'll use the hammer button. It will take some time. We can see information about the output data. So how big is the code? How much data we've got? What is the output file name? What was the time used for the completion? Now our next step would be to run the debug session. Okay, let's connect our boards. Of micro USB cable. You should see this red LED on the right side of the top connector turned on. It means that the driver is properly installed and our board is properly detected by the system. Once the board is connected, let's try to run the debug session. For this purpose, we've got this bug icon over here. Just press it. Now we've got a selection. How well we would like to debug this application? We will select the second option. So STM32, MCU, CC++ application. Okay. Now there's a space to edit the debug configuration. We will not do any modifications here. So let's just press OK. And now we can see again the warning about the perspective switch. You remember it for the first time when we started this project, there was a warning about the device configuration perspective. Now we will switch again from a CC++ perspective for editing the code into the debug perspective. I would press switch or if remember my decision, just not to waste time to click this window. All the time, I will go to the debug session. The difference we can see right now is that we can see bit different top bar which has some buttons which allows us to perform debug the application. So start the code execution. So we can see the resume, the code execution. You can see the suspend code execution. You can see terminate of the debug session. We can as well disconnect from the target. There are some components as well to go within the code. Let's just press resume to start our application. As a result, you should see green LED toggling half second on half second off to stop to disconnect from the target. You should press the terminate button. And now as a result, you will come back to CC++ perspective to continue the code processing. Thank you for watching this video.