Getting Started with STM32 and Nucleo Part 6: Timers and Timer Interrupts | Digi-Key Electronics

Описание к видео Getting Started with STM32 and Nucleo Part 6: Timers and Timer Interrupts | Digi-Key Electronics

In this tutorial, Shawn shows you how to set up timers in STM32 and use those timers to measure execution time, create non-blocking code, and trigger interrupts.

If you are not familiar with STM32CubeIDE, we recommend watching this video first:    • Getting Started with STM32 and Nucleo...  

We first cover the basics of timers in STM32. A timer is a piece of hardware in the microcontroller that continually increments a stored value each clock pulse it receives. Most general purpose timers in microcontrollers are connected to the main CPU clock through one or more prescalers. A prescaler acts to divide the cock. For example, an 80 MHz clock that goes through a prescaler of 80 would cause a timer to increment (tick) at a rate of 1 MHz.

These timers can be used to trigger interrupts to run arbitrary code at given intervals, measure the time between events, or automatically control hardware, as in the case of output compare and pulse width modulation (PWM).

We show you how to configure a timer using STM32CubeIDE by setting a prescaler and a maximum counter value. When a timer reaches this maximum value, it will reset back to 0 (for our chosen general purpose timer).

From there, we create a demo using the STM32 HAL framework to first read timer values to measure execution time of another piece of code. Then, we show how to use timer values to create a non-blocking blink example. Finally, we set up a timer interrupt that triggers once per second. In the interrupt handler, we simply toggle the LED.

Please note that we are using the Nucleo-L476RG for this video, which can be found here: https://www.digikey.com/product-detai...

Product Links:
Nucleo-L476RG - https://www.digikey.com/product-detai...

Related Videos:
Getting Started with STM32 and Nucleo Part 1: Introduction to STM32CubeIDE and Blinky
   • Getting Started with STM32 and Nucleo...  

Getting Started With STM32 and Nucleo Part 2: How to Use I2C to Read Temperature Sensor TMP102
   • Getting Started With STM32 and Nucleo...  

Getting Started With STM32 & Nucleo Part 4: Working with ADC and DMA
   • Getting Started With STM32 & Nucleo  ...  

Getting Started With STM32 and Nucleo Part 5: How to Use SPI
   • Getting Started with STM32 and Nucleo...  

Programming the Adafruit Feather STM32F405 Express with STM32CubeIDE
   • Programming the Adafruit Feather STM3...  

TinyML: Getting Started with STM32 X-CUBE-AI
   • TinyML: Getting Started with STM32 X-...  

Getting Started With STM32 and Nucleo Part 3: FreeRTOS - How To Run Multiple Threads w/ CMSIS-RTOS
   • Getting Started With STM32 and Nucleo...  

Related Project Links:
Getting Started with STM32 - Timers and Timer Interrupts - https://www.digikey.com/en/maker/proj...

Related Articles:
Getting Started with STM32 - How to Use SPI - https://www.digikey.com/en/maker/proj...
Making a Temperature Logger with the Adafruit Feather STM32F405 Express - https://www.digikey.com/en/maker/proj... -
TinyML: Getting Started with STM32 X-CUBE-AI - https://www.digikey.com/en/maker/proj...

Комментарии

Информация по комментариям в разработке