Using timers to trigger conversions

As sampling frequency plays such a critical role in determining the quality of the digital representation of the analog signal input, and to avoid aliasing artifacts, it is preferable to use a timer to trigger the conversion rather than to enable continuous conversions as we did in the previous recipe. This recipe, adcTimerISR_c5v0, illustrates this technique. The aim of this recipe is to configure TIM2 _CH2 in output compare mode so that it toggles every 100 ms and then use this timing signal to trigger the ADC.

How to do it…

  1. First create a new project called adcTimerISR.uvprojx and use the RTE manager to configure it as we did for the folder adcISR_c5v0 for the Setting up the ADC recipe.
  2. Copy timer.c and Custom_ADC.c ...

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.