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
- Study the op_amp_ini() function to see how OP0 is configured as a voltage follower with the DAC as an input.
- 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.
- In the
adc0_init() function, set VDDIO2DIV10 as an input to the
ADC by
writing:
ADC0.MUXPOS = ADC_MUXPOS_VDDIO2DIV10_gc;
- Verify that the solution/project builds by selecting the Build → Build Solution from the top menu bare in Atmel Studio or by pressing the F7 key.
- Flash the device by selecting the Debug → Start without debugging from the top menu bar in Atmel Studio or by pressing the Ctrl+Alt+F5 keys.
- 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.