 Hey, this is Troy with ST Microelectronics, and in this video I'm going to take you through an example project that uses the internal triggering system of the STM32 timers. The objective of this video is to give you a better understanding of how to use the timer's internal trigger feature, and to also demonstrate this feature with a hands-on project. For the demo project, we will create three PWM signals that are 120 degrees out of phase. This is just one use case of the internal triggering system, but keep in mind that it can also be used in many other ways, such as synchronizing the start of multiple timers. For this lab, we will be using an STM328745 nucleoboard, a micro USB cable for programming and powering the board, and an oscilloscope to measure the resultant PWM signal. There will be a link in the video description to a zip file that contains all relevant materials for the project. The only software tool needed for this project will be STM32 Cube IDE. The table to the right shows how the timer triggers are connected internally, and will be necessary to select the right timers for your application. This table can be found in the reference manual for the MCU. For this project, we will use timers 1, 2, and 3. Looking at the table, we can see that when Timer 2 is acting as a slave, it is connected internally to Timer 1 via ITR0. Likewise, when Timer 3 is acting as a slave, it is internally connected to Timer 2 via ITR1. This means we can cascade the 3 timers to create a 120 degree phase shift between the PWMs. This timing diagram shows how the 3 phases of the PWM will be triggered. Timer 1 Output Compare 1 generates the first phase of the PWMs. A third of the way through Timer 1 Output Compare 1's period, Timer 1 Output Compare 2 is set to high to trigger the second phase of the PWMs on Timer 2 Output Compare 1 via ITR0. Then Timer 2 Output Compare 2 is set to high a third of the way through Timer 2 Output Compare 1's period to generate the last phase of the PWM on Timer 3 Output Compare 1 via ITR1. When a timer is acting as a slave, there are different modes that dictate the way the triggering signal starts and stops the slave timer's counter. For this project, we will be using trigger mode, which means the slave timer's counter is started by the rising edge of the triggering signal. Definitions for the remaining configurations can be found in application note 4013. Now with the background knowledge out of the way, we can generate the project. First, let's launch STM32 cube IDE. Now select your workspace and launch. From the home page, select start new STM32 project. Once the target selection window opens, navigate to the board selector tab, then find the STM32-H745-ZIQ-NUHLEO board. Select next, enter a project name, and finish. Select yes for initialize all peripherals with their default mode, and select yes to open the device configuration perspective. Now that the device configuration tool is open, we can configure the three timers. First, navigate to Timer 1 in the timers tab. Select Cortex M7 runtime context, then activate PWM generation on channel 1, and output compare no output on channel 2. In the configuration, set the counter period to 9999. This was selected since it's easily divisible by 3, which will help us create the 120-degree phase shift. Next, select the trigger event selection as output compare channel 2, so that our output compare no output on channel 2 triggers the subsequent timer. Then, set the pulse on PWM channel 1. This number is arbitrary, set it to anything you'd like. Now lastly, for output compare channel 2, set to active level on match for the mode, and set the pulse to 3,333, which is a third of the counter period. The configuration for Timer 2 will be almost identical to that of Timer 1, except since we wanted to act as a slave, under slave mode, select trigger mode, and trigger source as ITR 0. Otherwise, all configurations are the same as Timer 1. Timer 3's configuration will be similar to that of Timer 2's. Slave mode as trigger mode. Now the trigger source will be ITR 1, but this time we only need PWM generation since we don't need an output compare to trigger another timer. Counter period and the pulse are the same as the previous Timer configurations. Now that the configuration is done, you can save the project and it will prompt you to generate code. Now you can either hit yes here or under project you can hit generate code. Once the code is done generating, the project will be opened in the project explorer. Now let's navigate to the main.c file associated with the CM7 project. Now open the phasedpwmcode.txt file found in the zip folder in the video description. Copy this code and paste it into the user code 2 section. Now with the code in place, we can build the projects. First, build the CM7 project. Right click on it and select build project. Once the CM7 project is built, build the CM4 project. With the CM4 project built, right click it and select run as STM32 Cortex-M application to upload it to the microcontroller. Select OK. Once the CM4 project is in the microcontroller, we can upload and debug the CM7 project. Right click the project and select debug as STM32 Cortex-M application. Select OK. Switch to debug perspective and click resume. Once the code is running, you can hook your oscilloscope up to these 3 GPIO pins and you will find that there are 3 PWM signals each 120 degrees out of phase. I hope this video was helpful. Thanks for watching.