In the datasheet of the SAM3X8E in Section 43.6.9 Page 1327 it clearly states that the SAM3X/A has a programmable offset for ADC input in Single-Ended mode and I believe that the Atmel ASF library also has a function dedicated to configuring analog offset for SAM's ADC (adc_enable_channel_input_offset
). However the following lines of code did not work:
adc_set_writeprotect(ADC,0);
adc_enable_anch(ADC);
adc_disable_channel_differential_input(ADC, ADC_CHANNEL_5);
adc_set_channel_input_gain(ADC, ADC_CHANNEL_5, ADC_GAINVALUE_2);
adc_enable_channel_input_offset(ADC, ADC_CHANNEL_5);
adc_set_writeprotect(ADC,1);
Why??