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: ...

Get ARM® Cortex® M4 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.