 Hello, and welcome on our STM32Cube IDE by Zeke's training session. In this section, I will demonstrate how to use USART to send the data, and how to visualize it using the terminal, which is built in within the STM32Cube IDE tool. So the objectives of this part are the following. I will demonstrate how to configure the USART to send the data, and then how we can reuse existing connection between USART of our microcontroller from the nuclear board to STA link, and then to use virtual comport on PC to communicate with the micro. And then we will reuse existing built-in terminal application, which is a part of STM32Cube IDE. Let's start from STM32Cube IDE new project creation. I would reuse an existing workspace, which contains already several projects. I would create a new one for our micro, so I go to file new STM32 project, and now I'm waiting for the target selection window. I'm selecting STM32G071RB microcontroller, so it's enough to type G071RB. This is this one, and we are selecting LQFP64 package version. So I create a click next, then the name of the project. I would propose G0 USART, and I will select C as a target language. I would like to generate the executable binary type, and we will use STM32Cube and its device configuration to create the skeleton of the application. Let's click finish to start device configuration window, which is in fact STM32CubeMix built-in with an STM32Cube IDE complete environment. So we see on the left side that our new project is already created, G0 USART. It's an empty skeleton, so now we can see the complete pin out of our micro. Nothing is connected yet, so let's start from connection of the debug interface. So system car says serial wire. We see that two pins has been already assigned, so this is the first point. Then we need to connect USART2, which is connected internally to the S-link. So we go to the connectivity, USART2, we select asynchronous mode, and then we see that PA2 and PA3 are assigned to USART2, TX and RX functions. And those two pins are connected to S-link on the S-link USART, and then are visible with virtual comport on PC once we connect our nuclear port to PC. Okay, so we've got a connection to USART, and now we can configure our USART parameters. So let's configure the parameters. I would propose to keep 115,000 bits per second as a boot write. Our work length is including parity. I would use 80 bits, and let's use even parity. Let's keep stop bits to one as a default settings. We will not do any additional configuration, so we can generate the project. I will just save the projects by Ctrl S, so there is a question whether we would like to generate a code. I would click remember my decision, and so yes, on the left part of the screen we can see that our template is filled with newly generated source files. Okay, so now we need to go into the source and the main.c file, which is the main file containing the sources which are executed after they are set. And within the main procedure we can see that we've got some initial configuration within the hull in it, then the clock configuration, which we kept as a default setting. So our system is called by HSI, so high speed internal oscillator, which is 16 MHz, and then we've got the initialization of the GPIOs and our USART tool. What we need to do right now, we need to transmit in some area data over the USART. So to do this, I would use our while one loop where I would put the function from USART domain, so hull underscore UART control space. And now I can see a lot of functions which are typical for G0 family, those with suffix EX, but I would select something typical, something easy. So I would like to transmit something without any IT, without any DMA, so I would select just simple hull UART transmit. The first argument is a handler to the UART we would like to use, then the pointer to the data we would like to send, then the size of those data and the timeout in milliseconds we would like to wait till the function will complete. So the first one would be UART 2, the second one, instead of the buffer, I would just specify the name, it would be test, test, space, and the size, it's five letters plus the end of the string, so it would be six, and the timeout let's put for example 100 milliseconds. Okay, to be sure that the function would be executed correctly without any errors, I would propose to check its return value and in case of any trouble, let's call the function, which is already generated, its error handler. It can be called in all of the cases when the hull function is returning value different from hull okay, which is the proper execution of the hull function. Okay, so I use if then it's not equal hull okay, then execute error, just correct the typing, okay, to not block our microcontroller, I would use some delay function at the end, hull delay, let's put here 500 milliseconds to make this string display visible. Okay, so this is all from the coding side. Let's try to compile the code, so I would build it. Okay, and now let's try to run a debug session. I select SDM32MCUCC++ application, this is the time I can change some configuration within the debug, I keep the default settings, and now I will switch to the debug perspective. Now we need to turn on the terminal window. And now being in a console window, now we are in a debug perspective, so we can see the dedicated debug tab with a resume, go search for a suspend and terminate debug session, in the bottom we can see the window with set of tabs. So console, registers, memory, outputs, we can set more registers, tabs, and the important is to select the console window, console tab. If you do not see any console, you can go to the window, show view, and console. Within the console tab, you need to go to the open console, and select command shell console, then select serial port, select new, select many connection type, so I would select test, test G0, then serial port, which has been assigned to your nuclear port, in my case it is com31, border it like set in our configuration within the device configuration, so it was 115,000, data size, it was set to 8 including parity, so I would set to 7, because we are using even parity, and the stock bits is 1. I click finish, I can select as well the encoding, one of the three options we've got here, but I do not use any special characters, so I use the default setting, and then I press OK. So I can see that my terminal is connected, now if I run the application by pressing the rhythm button, I can see once per half a second the text I would like to display. Now I can disconnect the terminal, just pressing this icon, I can connect it once again, it will continue, please be careful once you disconnect the terminal, and then you forget to close the console, because in this case if you try to create a new terminal application, it will be not possible, it will be not possible because there is already open connection on different name, on the same serial port. Thank you for watching this video.