 Hello, and welcome to this presentation. My name is Badrini, and in this video, we'll learn how to use the GraphWidget to display the ADC converted values. In the first part of this video, we learned how to set up the GraphWidget .gfx designer. In this second part, we'll see how to set up the ADC and pass the converted values to the GraphWidget. Here I have my .gfx files. I'll go up by one level here and double click on STM32-H7B-IUC file. I get my STM32 Cuba Max project open here. I go to Pinout and Configuration. And here, I'll select one of the ADC channels are connected to Arduino connector. So I will check the schematic of the board. Here I have PA4 connected to Arduino connector, connector 20, pin 1, and this is ADC1 channel 18. So PA4 is used or can be used as ADC1 channel 18. I go back to STM32 Cuba Max, and I enable channel 18 single-ended. And I can see here PA4 is set up as ADC channel 18. Next, I will set up few parameters of the ADC, parameter settings. I'll keep the ADC in 16-bit resolution. I will use external trigger conversion. I will use timer 1, capture compare 1 event. And then I'll keep the default edge, which is the rising edge. So what I want to do is whenever a timer 1 channel 1 event happens, ADC starts the conversion. So I will set up the timer 1, channel 1 as a PWM generation channel 1. And then I will set up the scalar or prescalar to 140 minus 1 to show that the prescalar value of 131 actually means the clock is divided by 140. So this means the counter will increment every 1 microsecond. So here we see that the timer, ABB1 and ABB2 timers are clocked by 140 megahertz. 140 megahertz divided by 140 gives us 1 megahertz. Next, I will set the period to 16,000 minus 1. This means the counter will overflow every 16,000 ticks or every 16 millisecond. Next, I will set the pulse value to 16,000 divided by 2 to get a duty cycle or PWM duty cycle of 50%. So here what I did is I generated a PWM signal with a period of 16 millisecond and a duty cycle of 50%. I go back to ADC here and enable the NVIC settings. So here every 16 milliseconds, a timer compare event triggers an ADC conversion. Once the conversion is done, an ADC interrupt is kicked off. I'll set the project and generate code. I'll click on Open Project. STM32QBID asks me to select a directory for the workspace. I'll just select a path for it. And here I have my STM32QBID project. I close the Information Center. I expand my project here and then Application and then User. And I go to or select Main.C. So I'll start by the timer configuration. So here we have timer one in it. And here we have the prescaler. We have the period. And we have the duty cycle or the pulse value. And here we want to add the API to start the timer counter. So here we'll use the Hall API, Hall Timer PWM start channel one. So this will start the timer counter. Then we'll go to the ADC init function. So here we have timer one, channel one, used as external trigger conversion for the ADC. And here we have the rising edge selected for the conversion. So here we have channel 18, sample time one, 1.5. So here in the user code section, I will start the ADC. So the API is Hall ADC start ADC. So we'll use the interrupt model to start the ADC conversion. So whenever the ADC finishes the conversion, an ADC interrupt will happen. I have here the ADC interrupt enabled. And what I still need to do is to enable the timer or the ADC callback. And the callback is how ADC conversion complete callback. And here we use a variable to retrieve or read the ADC converted value. So we still need to enable or define this variable. We'll go up here in the private variable definition. I will set it as volatile and a 16-bit variable. Next, I will send this ADC converted data to the graph widget. I will start by expanding GUI folder here and then model.cpp. Here the model has the take method that gets called every 16 millisecond. I will call model listener update graph ADC converted value times 3,300. This is the max value given that ADC can convert and divided by the 535. This is the 16-bit value for 3.3 volt or 3,300 volt. Next, I will define the ADC converted value as extern. Here I'll use it as extern. And I still need to include 8stm32h7hal.h file. OK, next I will define this method in the model listener. I'll click on the model listener. Create a new virtual void function with update graph. I need to include the types. Then we go to the presenter.scannerpresenter.cpp. We'll create a new method update graph. And this method calls the view update graph. We define this method in the .hpp file update graph. Then we go to screen one view .cpp. We create a new method update graph. And this update graph method calls dynamic graph one add data point. And this is the value we get from the ADC. So this is the result of ADC converted value times 3,300 divided by 635. We want to create or define the method in the header file. Now I'm ready to build. I click on build button. The build finished successfully. Now I'm ready to download the application. I click on debug button here. Remember my decision and switch. Download the file successfully. I proceed to code execution. Here I have my STM32H7B discovery board. I have my waveform generator connected to the Arduino connector. And here I have my sine wave displayed on the graph widget. I'll change the waveform to square. And here I have the waveform changed. Thank you for joining me in this video. And we hope that you enjoyed learning how to use the graph widget to display the ADC converted values.