This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR5994: Reading multiple ADC channels

Part Number: MSP430FR5994

Tool/software:

I am trying to read from A3 and A4 inputs to the processor. I can read A3 fine, but when I try and read A4, I get the same value. With the debugger I can see that I am correctly changing ADC12MCTL0 depending on which parameter I call the function with, so I am assuming there is something else wrong with how I am reading the result registers? Any help would be greatly appreciated.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
uint16_t adcResult = 0x0000;
void initADC(){
while(REFCTL0 & REFGENBUSY); // If ref generator busy, WAIT
REFCTL0 |= REFVSEL_2 | REFON; // Select internal ref = 2.5V
ADC12CTL0 = ADC12SHT0_2 | ADC12ON;
ADC12CTL1 = ADC12SHP; // ADCCLK = MODOSC; sampling timer
ADC12CTL2 |= ADC12RES_2; // 12-bit conversion results
}
uint16_t sampleADC(ADC_Input channel){
//select right channels from the ADC
switch(channel){
case ADC_CH_REG_3V3:
ADC12MCTL0 = ADC12INCH_4 | ADC12VRSEL_1; // A1 ADC input select; Vref=+VRef
break;
case ADC_CH_INA241:
ADC12MCTL0 = ADC12INCH_3 | ADC12VRSEL_1;
break;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

**Attention** This is a public forum