Programmable Gain Amplifier

The Programmable Gain Amplifier (PGA) can be used to amplify the input signal to the ADC. The available range is from 1x to 16x gain. The PGA is enabled by writing a ‘1’ to the PGA Enable (PGAEN) bit and configuring the GAIN bit field in the PGA Control (ADCn.PGACTRL) register.

ADC0.PGACTRL |= ADC_GAIN_16X_gc | ADC_PGAEN_bm; /* Enable the PGA with 16x gain */
Note: PGA Control is one of few AVR registers with a nonzero reset value. This must be taken into account if only configuring parts of the register.

When PGA is enabled, the configuration of the VIA bit fields in the Positive and Negative Multiplexer (ADCn.MUXPOS and ADCn.MUXNEG) registers is required. The VIA bits are shared, so a value written to the VIA bit field in MUXPOS or MUXNEG is updated in both registers. It is, therefore, not possible to have one input using the PGA and the other not using the PGA.

ADC0.MUXPOS |= ADC_VIA_gm;  /* Enable VIA */