I want to increase gain of the ADC channel. To achieve this I'm using adc_set_channel_input_gain
function from adc.h. Here is the entire sketch:
const byte aPin = A6;
void setup() {
analogReadResolution(12);
// Configure ADC gain
// Arduino/hardware/arduino/sam/system/libsam/include/adc.h
adc_channel_num_t ch = (adc_channel_num_t)(g_APinDescription[aPin].ulADCChannelNumber);
adc_set_channel_input_gain(ADC, ch, ADC_GAINVALUE_3);
Serial.begin(9600);
// Delay for serial stabilization
Serial.println("Begin.");
delay(2000);
}
void loop() {
int analog = analogRead(aPin);
Serial.println(analog);
delay(500);
}
The problem is that output values are not depending on the gain value.
adc_set_channel_input_gain()
is not compliant with the basic analog input library which use onlyanalogReadResolution()
andanalogRead()
. Please read more aboutadc_init(ADC...
for the "sam3x".