Setting up the ADC

The aim of this recipe is to configure the ADC in single-conversion mode and then convert the voltage set by the thumbwheel into a 12-bit digital value. We'll configure the ADC to generate an interrupt at the end of each conversion and write an interrupt handler to read the ADC and initiate a new conversion. The only task for our main function to perform is to output the ADC value to the LEDs, but as there are only 8 LEDs we can only display the most-significant 8-bits of the ADC value. We'll call this recipe adcISR_c5v0.

How to do it…

To set up the ADC follow the steps outlined:

  1. Open a new folder named adcISR_c5v0 and create a new project named adcISR.uvprojx.
  2. Select LED (API) from RTE Board Support but do not select A/D converter ...

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.