 Hello, my name is Andre Barata and I would like to welcome you all to the second session of STM32L4 MOOC training. Today's session is about external interrupts. So the objective of this session is to learn how to set up and use external interrupts by creating a program to toggle an LED whenever the user presses a button. To do so, we will use STM32 Cubemix to configure and generate code for both the LED pin on PE8 and the pin for external interrupts. This external interrupt is going to be carefully selected from the blue joystick made available on the STM32L4 Discovery board. In this case, we will be using the central key of the joystick, which is directly wired to PA0. Regarding code, apart from the toggling function, we will need to include the service routine callback. This routine will be called after every single external stimulus, and inside of this routine, this toggling function should be placed. After this introduction, let's get started by opening the STM32 Cubemix. Already with the Cubemix open, we are going once more to start a new project. When the menu opens, we are going to type STM32L476VG, select the according part number and start the project. As in the previous episode, we are going to define PE8 as GPIO output for the LED pins. For this one, we will need PA0 as being defined as GPIO external interrupt. After both pins have been selected, we need to go to the configuration tab, go to GPIO as in the previous episode, we will leave everything as it is, the standard configuration. On PA0, you can select the mode of detection of external interrupt. In this case, you can select from rising edge, falling edge or both. For the purpose of our program, we can leave it as rising edge detection. After the GPIO configuration is done, we need to go to the NVict, which stands for nested vector interrupt controller, and we need to enable external interrupt line zero interrupt. After all configurations have been done, we just need to go to file, save project as, save it in an appropriate place, give it an appropriate name, save the file, go to project, settings, select the file name, project location if we are fine with this location. Yes, it can be, choose once again the tool chain that we plan to use and once again we will be using our system workbench for STM32, we press OK and we are ready to generate the code. After code is generated, we just need simply to open the project. After the loading is done, I would recommend to inspect the code initializations before proceeding, just to make us comfortable inside of the generated project. As you recall, we need to start by implementing the service routine callback, since the source of external interrupt is the GPIO we need to search inside of the source, GPIO, and here we are going to look for the weak function. This small part of the GPIO service call routine, we should copy it to our main function. Here I would recommend to paste the routine inside of user code begin4, we can close our find and replace window and delete all the content inside of the callback routine. It is important that you keep the code inside the user code begin4, and then, since if you need to regenerate the code once more by using STM32 cube and mix, these fractions of code won't be lost. To conclude our program, we just need to add our callback routine to the function prototypes, and inside of our routine callback, we need to add the toggle function. As more than one online can be used to generate external interrupts, we need to add an e-verification to make sure it was GPIO pin 0 generating the interrupt. And here we are going to place our HAL GPIO tagging function. If you are in doubt on what to put in which field, you can simply go here and as you can see they will tell you which parameters you should place in which side. In our case it will be GPIO port E and the pin is the pin 8 as you recall, the one which is directly attached to our LED. If everything went accordingly, we just need to debug our project and flash it into our board and we should be ready to go. After all the modifications have been done, you will build your project by pressing the hammer button here. If you are not supposed to have any kind of error or warning message, you will start debug our project. When you enter the debug mode, you just need to press play to resume our application which means that you are going to run it. And if you hold your discovery board by press the central blue key on the joystick, you will see your LED tagging on and if you press it once more, you will see it turning off. If you press it once again, it will be on again and off again. Thank you for watching.