7.2 Measuring VDDIO2 Using the ADC

Todo:
  • Understand how the op amp and DAC combine to create a power supply for VDDIO2
  • Edit adc0_init() so it configures the ADC to measure VDDIO2
  • Plot the measured VDDIO2 values in MPLAB® Data Visualizer
  1. Study the op_amp_ini() function to see how OP0 is configured as a voltage follower with the DAC as an input.
  2. Study the dac_init() function to see how it outputs a constant voltage called VDDIO2, which is defined in dac.h.
    Info: Combining the DAC and op amp with the hardware modifications used earlier in this assignment, the op amp will be a power supply for VDDIO2. This is illustrated in Figure   1.
    Figure 7-4. Assignment 5: Op Amp as a Power Supply
  3. In the adc0_init() function, set VDDIO2DIV10 as an input to the ADC by writing:
    ADC0.MUXPOS = ADC_MUXPOS_VDDIO2DIV10_gc;
  4. Verify that the solution/project builds by selecting the Build Main Project from the top menu bare in MPLAB® X or by pressing the F11 key.
  5. Flash the device by selecting the Make and Program Device Main Project from the top menu bar in MPLAB® X.
  6. Plot the measured ADC reading in the MPLAB® Data Visualizer by loading the workspace Assignment6.json.
Result: The ADC measurements are plotted in MPLAB® Data Visualizer, as shown in Figure   2. Note that the unit is millivolts.
Figure 7-5. Assignment 5: Result