I want to use the adc to measure 9 different inputs. I configured the ADC_SAR_Seq to be single ended with
input range: vssa to vdda
Reference: internal Vref
voltage reference: 2.5 volts (vdda/2)
Free running and internal clock source.
The code is simple, I start the adc and start the conversion and then create a for-loop and read the results in 16 bit, then I convert those results to voltages:
int16 ch1, ch2, ch3, ch4, ch5,......,ch9;
float32 volt1, volt2, volt3, volt4, volt5,...,volt9;
ch1 = ADC_SAR_Seq_GetResult16(0);
ch2 = ADC_SAR_Seq_GetResult16(1);
volt1 = ADC_SAR_Seq_CountsTo_Volts(ch1);
volt2 = ADC_SAR_Seq_CountsTo_Volts(ch2);
I am able to measure the pins manually to check if the adc measurements are correct, and I am able to put 5V on one of the pins.
What I would expect is for one of the adc measured pins to return a value of 5 volts and the rest to return the value 0,
but I get results where all of my measurements are approximately the same value (about 5 when I put the 5V on one pin and 0.1 when there is nothing on the pins).
I know that the correct voltages of the pins are 0 for the ones who are not connected to the 5 volt for the connected one. Therefore I am very confused by these results, does anyone know why this happens and how to fix it?
Can it be that you leave the pins floating? There is no expected value in this case.