STM32 LED Blink Using the Timer


In this experiment, we are going to use the timer interrupt to perform Led blinking operation and to check the time.

To perform several tasks at a time we use the timer interrupt.

Step 1: Configuration of the board

Select that STM32CubeMX In this screen you select the new project. After selecting a new project you get this screen.

Step 2: In this screen, you can select required STM board. Now here I am going to select an STM32f0R8 series.

Step 3: configuring the stm board by setting the clock, input and output pins.

Select the serial wire and timer pin, you can select any timer here we are using TIM3.

In TIM3 select the clock source as internal clock ad We are going to selected 9th pin as an output pin. As shown below

Step 4: Setting the clock configuration.

In the configuration window, we will get the timer which you have chosen here I am using TIM3.

Step 5: Click on the timer you have chosen. you will get below window In the parameter setting, we are going to add the prescaler value which is 16 bits and the counter period.

Step 6: Enable the timer by choosing the timer global interrupt.

Step 7: Now we have to save our project. Give a project name and browse the location where you want you save it.

Select the toolchain/ IDE which you are using, I am using MDK-ARM V5. OTHER SETTINGS ARE KEPT AS IT IS. CHECK BELOW FIGURE.

Step 8: Now our code is generated. We will open the project directly through keil.

Step 9: In this keil select the Application user you will get the  main.c.

 In main.c we can write the program.

Connect the stm32f0308 kit to computer using the data cable.

After writing the program.

  • build the program(shortcut press key-F7).
  • load(F8).
  • start/stop debug the program (ctrl+F5).

we got the disassembly screen. Here we can run the program

Step 10: Run the program(F5).

Step 11: If everything goes correctly we can see the LED blinking on STM board.