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: ADC Result Same for all ADC channels

Part Number: MSP430FR5994


Hi

  I am using a function named 'HAL_readAdcRawValue' to read the ADC counts value. The parameter passed to the function is the ADC channel number as used in the project. Internal to the function, the passed on channel number is converted to the desired ADC channel number using switch-case.

  The issue I am currently facing is that, the first ADC read value is getting copied for all channels. For example, if the first call to this function is for channel 1, then all subsequent channel read requests are actually reading channel 1 only.

  Is there anything wrong in the function?

-----------------------------------

uint16_t HAL_readAdcRawValue(uint8_t channelId_u8)
{
uint16_t adcRawValue_u16;
//Configure Memory Buffer
// * Base address of the ADC12 Module
// * Configure memory buffer 0
// * Map input A0 to memory buffer 0
// * Vref+ = AVcc
// * Vref- = EXT Positive
// * Memory buffer 0 is not the end of a sequence
ADC12_B_configureMemoryParam configureMemoryParam = {0};
configureMemoryParam.memoryBufferControlIndex = ADC12_B_MEMORY_0;

// SELECT CHANNEL

switch(channelId_u8)
{
case ADC_CHANNEL_BATTERY_VOLT_MONITOR:// P1.0
configureMemoryParam.inputSourceSelect = ADC12_B_INPUT_A0;
break;
case ADC_CHANNEL_PRESSURE_VALUE_MONITOR:// P1.1
configureMemoryParam.inputSourceSelect = ADC12_B_INPUT_A1;
break;
case ADC_CHANNEL_PRESSURE_SUPPLY_VOLT_MONITOR:// P4.3
configureMemoryParam.inputSourceSelect = ADC12_B_INPUT_A11;
break;
case ADC_CHANNEL_ANALOG_IN_1:// P4.1
configureMemoryParam.inputSourceSelect = ADC12_B_INPUT_A9;
break;
case ADC_CHANNEL_ANALOG_IN_2:// P4.2
configureMemoryParam.inputSourceSelect = ADC12_B_INPUT_A10;
break;
case ADC_CHANNEL_TC:// P3.1
configureMemoryParam.inputSourceSelect = ADC12_B_INPUT_A13;
break;
default:
configureMemoryParam.inputSourceSelect = ADC12_B_INPUT_TCMAP;//ADC12_B_INPUT_A0;
break;
}

configureMemoryParam.refVoltageSourceSelect = ADC12_B_VREFPOS_INTBUF_VREFNEG_VSS;//ADC12_B_VREFPOS_EXTPOS_VREFNEG_VSS;
configureMemoryParam.endOfSequence = ADC12_B_NOTENDOFSEQUENCE;
configureMemoryParam.windowComparatorSelect = ADC12_B_WINDOW_COMPARATOR_DISABLE;
configureMemoryParam.differentialModeSelect = ADC12_B_DIFFERENTIAL_MODE_DISABLE;
ADC12_B_configureMemory(ADC12_B_BASE, &configureMemoryParam);

// Configure internal reference
while(Ref_A_isRefGenBusy(REF_A_BASE)); // If ref generator busy, WAIT
Ref_A_enableTempSensor(REF_A_BASE);
Ref_A_setReferenceVoltage(REF_A_BASE, REF_A_VREF2_0V);
Ref_A_enableReferenceVoltage(REF_A_BASE);

DELAY_MS(10);

//Enable/Start first sampling and conversion cycle
// * Base address of ADC12 Module
// * Start the conversion into memory buffer 0
// * Use the single-channel, single-conversion mode
ADC12_B_startConversion(ADC12_B_BASE, ADC12_B_MEMORY_0, ADC12_B_SINGLECHANNEL);

//Poll for interrupt on memory buffer 0
while (!ADC12_B_getInterruptStatus(ADC12_B_BASE, 0, ADC12_B_IFG0));

adcRawValue_u16 = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_0);


return(adcRawValue_u16);
}

-----------------------------------

Thanks

-

Regards

Soumyajit

**Attention** This is a public forum