6 Using DAC as Negative Input for AC
As seen in Figure 6-1, the AC can use the DAC output as the negative input. Therefore, the user can generate the AC negative voltage reference by simply writing the corresponding digital value to the DATA register of the DAC peripheral module. Then, the DAC will generate the conversion result, a constant voltage, which will be directly connected to the AC input.
In this code example, the voltage reference for the DAC module is configured at 1.5V.
VREF.CTRLA |= VREF_DAC0REFSEL_1V5_gc;
VREF.CTRLB |= VREF_DAC0REFEN_bm;
_delay_us(VREF_STARTUP_MICROS);
The AC is configured to receive its negative input from DAC and positive input from pin PA7.
AC0.MUXCTRLA = AC_MUXNEG_DAC_gc | AC_MUXPOS_PIN0_gc;
Pin PA5 is configured as the AC output.
AC0.CTRLA = AC_ENABLE_bm | AC_OUTEN_bm | AC_RUNSTDBY_bm | AC_LPMODE_bm;
After initializing the VREF, DAC, and AC, the DAC output is set to 1.4V.
DAC0_setVal(DAC_DATA_1V4);
The AC will compare the voltage from PA7 to 1.4V and set its output according to the comparison result.
This application can be implemented on AVR128DA48 by using the internal reference voltage generator (DACREF) feature of the AC. There is no need to configure the DAC to provide a negative input for the AC on this architecture.