O'Reilly logo

ARM® Cortex® M4 Cookbook by Dr. Mark Fisher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Configuring general-purpose timers

The idea of this recipe, which we'll call timerISR_c5v0, is to use a general purpose timer (TIM2) to generate an interrupt every 100 ms (that is, 10 Hz). The interrupt handler maintains a counter that, in turn, sets the global variables, LEDOn, LEDOff, which are used within main () to flash the LEDs.

How to do it…

Follow the steps to configure general purpose timers:

  1. Create a new recipe (folder) named timerISR_c5v0. Invoke uVision5 and create a new project named timerISR.uvprojx.
  2. Select the LED (API) driver from the RTE Board Support drop-down menu and configure CMSIS and Device options as in previous projects.
  3. Create a new file, name it timerISR.c, and enter the following statements. Remember to include the boilerplate: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required