 Hello and welcome to the STM32L for MOOC online training. My name is André Barat and this is the dedicated session for the DAC brief role. Let's have a look at the Digital to Analog converter or in short DAC. It's used to convert digital signals to analog voltage which can interface with external world. The Digital to Analog converter on STM32L products ensures the conversion of 8 or 12 bits digital data to analog voltage. On this session we will learn how to set up and generate code for the DAC brief role on STM32QMX. The main objective is to use the DAC to generate the sawtooth signal and measure it with an oscilloscope or a multimeter. The DAC output signal will be made available on PA5 on our Discovery L4 board. Let's now open STM32QMX to configure the DAC for this hands-on. As a first step we will click on new project. On the new open window we will type our part number STM32L476VG and we will double click on the desired part. Let's start our configuration by going to DAC1 and we will select on out to the connect to external pin only option. We can measure the output waveform on this pin. We will leave the clock configuration as default so we can skip this step. On the configuration tab we can verify the DAC configuration settings. The output buffer is enabled as it should, so as everything is properly set we can just save our project and generate our code using system workbench for STM32 as our IDE. After the code is generated by the STM32QMX and our project is loaded on system workbench for STM32 we will open our main.c file stored inside the source folder. On main.c file you are supposed to see the initialization of all peripherals defined on STM32QMX. In this specific case we can see the system clock configuration and DAC initialization. As a first step we will initialize one variable on user code private variables section for output DAC value named value underscore DAC. Let's now go to the user code section 2 and start our DAC. We will start by setting the DAC output value so we will use the function HAL underscore set value and the parameters will be the DAC handler, the DAC channel number, the alignment which in this case is a 12-bit long alignment to the right and finally the output value for the DAC. Then inside of a if conditional statement we will check if the DAC value is lower than 4095 which is our maximum output value for a 12-bit resolution DAC. If the value is lower than the maximum value we will increment it, if not we will reset it back to zero. We will add some delay could be 1 millisecond in order to have a stable output value and this will be all the code we need in the infinite loop. The code we just typed will sweep through all the DAC output possible values in roughly 4 seconds and then reset it to zero restarting the process all over again. Now we can build the project and upload our code to the discovery board. And if we restart the board and attach a multimeter to the PA5 pin we will see that the DAC output gradually increases up to a maximum output value which is 3 volt. Then it will go back to zero forming a sawtooth wave. This will be all on this hands-on session. Thank you for watching.