I am using ATXmega16A4U. VCC & AVCC are at 3.3V. ARef is at 2.49V (measured), but the ADC saturates (reading 4095) at 2.37V. I have tried both single ended and differential inputs (negative pin tied to ground). The latter saturates even earlier.
In my application, I need the readings close to Aref. Please advise.
#define ADCACAL0 offsetof(NVM_PROD_SIGNATURES_t, ADCACAL0) #define ADCACAL1 offsetof(NVM_PROD_SIGNATURES_t, ADCACAL1) void ADC_Calibrate() { ADCA.CALL = nvm_read_production_signature_row(ADCACAL0); ADCA.CALH = nvm_read_production_signature_row(ADCACAL1); } void ADC_init(void) { PORTB.DIRCLR = PIN0_bm|PIN1_bm|PIN2_bm|PIN3_bm; sysclk_enable_peripheral_clock(&ADCA); ADC_Calibrate(); ADCA.CTRLB = ADC_RESOLUTION_12BIT_gc; ADCA.REFCTRL = ADC_REFSEL_AREFB_gc; ADCA.PRESCALER = ADC_PRESCALER_DIV128_gc; ADCA.CH0.CTRL = ADC_CH_INPUTMODE_SINGLEENDED_gc | ADC_CH_GAIN_1X_gc; ADCA.CH0.MUXCTRL = ADC_CH_MUXPOS_PIN9_gc; ADCA.CTRLA = ADC_ENABLE_bm; }