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.

MSP432P401R: [URGENT] ADC Analog In Pin Not Working

Part Number: MSP432P401R

Hi,

I'm using the MSP432P401R Launchpad. I'm trying to do an ADC conversion by applying my analog signal to PIN 6.0 on the launchpad. The code I have written to configure the ADC in the main method and the ADC ISR are as follows:

#include "msp.h"


/**
 * main.c
 */
#include "myLib.h"

void main(void) {
    WDT_A_holdTimer();   // stop Watch Dog timer

    //Configuring GPIO Pins:
    GPIO_setAsOutputPin(p2, PIN7); //Relay Control pin init()
    GPIO_setOutputLowOnPin(p2, PIN7);
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6, GPIO_PIN0, GPIO_TERTIARY_MODULE_FUNCTION); //Analog In Pin init

    //Configuring Clock:
    unsigned int dcoFrequency = 3E+6;   //sets clock frequency for the system
    CS_setDCOFrequency(dcoFrequency);   //sets the frequency
    CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1); //starts the oscillator

    //Configuring Timer:
    Timer_A_configureUpMode(TIMER_A0_BASE, &upConfig_0); // Configure Timer A using above struct
    Interrupt_enableInterrupt(INT_TA0_0); // Enable Timer A interrupt
    Timer_A_startCounter(TIMER_A0_BASE, TIMER_A_UP_MODE); // Start Timer A

    //Configuring ADC Module:
    // Initializing ADC (MCLK/1/4)
    ADC14_enableModule();
    ADC14_setResolution(ADC_10BIT);
    ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_4, 0);

    //Configuring ADC Memory
    ADC14_configureSingleSampleMode(ADC_MEM0, true);
    ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_AVCC_VREFNEG_VSS, ADC_INPUT_A0,  false);

    // Configuring Sample Timer for ADC:
    ADC14_enableSampleTimer(ADC_MANUAL_ITERATION);

    //Enabling/Toggling Conversion for ADC:
    ADC14_enableConversion();
    ADC14_toggleConversionTrigger();

    //Enabling Interrupts:
    Interrupt_enableMaster();

    //Critical Load Operation:
    while (1) {
    }
}

void timerA_isr(){
    Timer_A_clearCaptureCompareInterrupt(TIMER_A0_BASE, TIMER_A_CAPTURECOMPARE_REGISTER_0);
    ADC14_toggleConversionTrigger(); //toggles every time in isr
    uint_fast16_t digital;
    while (ADC14_isBusy()) {}
    digital =  ADC14_getResult(ADC_MEM0);

    //Data Conversion and Printing:
    float voltage = 0.0;
    voltage = (digital*3.3);
    voltage = (voltage/1024);
    avg[count] = voltage;
    count++;
    if(count >= 10) {
        count = 0;
    }
    
    Vbus = (avg[0] + avg[1] + avg[2] + avg[3] + avg[4] + avg[5]+avg[6]+avg[7]+avg[8]+avg[9])/10;
    printf("%.3f \n", Vbus);
}

The problem is: when I apply a 1.5V signal to PIN 6.0, I only see a constant 0.141V value in Code Composer Studio using expressions for the "VBus" variable. When I switch the ADC Analog In pin configuration to pin 5.5 using the GPIO_setAsPeripheralModuleFunctionInputPin() API, everything works fine and I see 1.5V in CCS. 

Could I please get some help in getting this to work for PIN 6.0, which is also an Analog Pin according to the Pin configuration? Is there something I'm doing wrong in the basic setup?

The reason I can't use any other pin is because I've already gotten a PCB made that uses PIN 6.0 from the launchpad.