 Hello and welcome to the STM32L for MOOC online training. My name is Andre Barata and I'll guide you through the general purpose timer hands-on session. In this exercise we will show how to toggle the green LED using the timer in PWM mode. On this session we will learn how to setup and generate code for the timer peripheral on STM32QMX. The timer will be configured with a period of 1hz and 50% of the cycle. The output signal of the timer will drive the green LED so we will be able to verify if the timer is correctly working. Let's now open the STM32QMX to configure the timer for this hands-on. As a first step we will click on new project. On the open window we will type our part number STM32L476VG and we will double click on the desired part. If we open the options available on PE8 we can see that one of the possibilities is the timer 1 channel 1 negative output. If you also recall this pin is directly connected to the green LED so we need to configure the timer 1 in channel 1 to be able to control and toggle the green LED. So we will proceed to select from the peripheral 3 timer 1 and on channel 1 we will select PWM generation SH1N. Next we need to select a clock source for this timer and on this case we will use internal clock source. As a result of this configuration the pin PA7 was highlighted in green and now we need to remap it to the PE8 by holding the control key and drag and dropping it to PE8. In the clock configuration tab let's choose the clock frequency for the microcontroller. In this case will be the maximum which is 80 MHz. STM32QMX will handle all the configuration changes for us so we can accept a proposal to resolve automatically and move to the configuration tab. In the configuration tab we just need to adjust the PWM parameters to fulfill the requirements of our application. So we will go to control timer 1. So we need to achieve 1Hz output frequency of the timer. As we have 80 MHz input frequency in the timer we need first to divide it by 1k-1 or 7999. We have to subtract 1 as we are starting from 0. So we will have 10kHz after the pre-scaler division which means we just need to set the auto-reload register to 10k-1 to have our intended 1 second period. So in the PWM generation SH1N we will set PWM mode 1 and the pulse with a 50% dot d cycle or 5k. As everything is configured we can just save and generate the code using system workbench for STM32 as our IDE. After the code is generated by the STM32QMX and our project is fully loaded on system workbench for STM32 we will open our main.c file stored inside the source folder. Our 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 GPIO and timer unit which will be in focus on this session. This hands-on will not be very complicated in terms of code as we just need one line to start the timer to complete our example. We will go to the user section number 2 and type hl time ex the suffix ex denominated that this function is specific from this family so its implementation is included on the extension files. In this case the channel negative is one of the unique features of the L4 family. hl time ex press control space to see the available options PWM start and if we go into the function we can see that the parameters will be the timer one handler and the number of the channel now we can build the project and upload our code to the discovery board if we restart the board after uploading we should see the green LED toggling this will be all for this hands-on session thank you for watching