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.

ADC MSP430FR4133 to external input with driverlib

I am just starting with the FR4133 Launchpad. I want to read an external voltage on A8 (P8.0) using driverlib. I get 0 as the return value (ADCvalue) from the getResults call . Code:

uint16_t ADCvalue;

// Configure A to D

GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P8, GPIO_PIN0, GPIO_TERNARY_MODULE_FUNCTION);

ADC_init (ADC_BASE, ADC_SAMPLEHOLDSOURCE_SC, ADC_CLOCKSOURCE_ADCOSC, ADC_CLOCKDIVIDER_1);

ADC_enable(ADC_BASE);

ADC_setupSamplingTimer(ADC_BASE,ADC_CYCLEHOLD_8_CYCLES,ADC_MULTIPLESAMPLESDISABLE);

ADC_configureMemory(ADC_BASE, ADC_INPUT_A8, ADC_VREFPOS_AVCC, ADC_VREFNEG_AVSS);

 while (1)

{

ADC_startConversion (ADC_BASE, ADC_SINGLECHANNEL);

while (!(ADC_getInterruptStatus(ADC_BASE,ADC_COMPLETED_INTERRUPT_FLAG))) ;

ADCvalue = ADC_getResults(ADC_BASE);

ADC_clearInterrupt(ADC_BASE, ADC_COMPLETED_INTERRUPT_FLAG);

}

}

Any idea why this is not returning results?

  • And the answer is... replace the GPIO_setAsPeripheralModuleFunction.. with enabling the port for analog, using SYSCFG2 |= ADCPCTL8; Now reading analog into my Launchpad.
  • The best answers are those you find yourself :-)

    But thanks a lot for telling it! Most people that find the answer themselves don't do that which will lead to other people sitting there posting possible reasons/solutions and the one who asked for it will never come back and look and therefore will not verify it/mark it as solved.

**Attention** This is a public forum