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
.
To set up the ADC follow the steps outlined:
Open a new folder named
adcISR_c5v0
and create a new project namedadcISR.uvprojx
.Select LED (API) from RTE Board Support but do not select A/D converter (we will write our own code for this). Set the CMSIS and Device software components as for previous projects. Be sure to select resolve so that the correct runtime environment (RTE) is included.
Create an
adcISR.c
file (the main function) and enter...