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: msp432 adc conversion issue

Part Number: MSP432P401R

Hi,

I am using msp432 internal ADC at 2.5V  ref voltage with 14bit resolution. But with an input voltage of 1.6 V, I am getting 1.1V after conversion. There is a difference of 0.5 V. Even with a non RTOS code provided by TI, the value i get is 1.2 V for the same condition..

Please suggest how I can improve the accuracy of the reading? Also, How much tolerance should I consider for conversion results?

Thankyou,

- Suraj

  • Can you share your setup code and code to calculate the voltage?

    Are you measuring a DC or AC voltage? Did you check with a multimeter to make sure that you have 1.6V on the pin?
  • ADC14_enableModule();
        ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1, 0);
    
            ADC14_configureSingleSampleMode(ADC_MEM0, true);
    
        /* Setting up GPIO pins as analog inputs including reference*/
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5,
                GPIO_PIN7 | GPIO_PIN6 | GPIO_PIN5 | GPIO_PIN4 | GPIO_PIN3, GPIO_TERTIARY_MODULE_FUNCTION);
    
    
    int16 ADC_ReadValue (enumtype Channel)
    {
        switch (Channel)
        {
        case Sensor0 :
            ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_EXTPOS_VREFNEG_EXTNEG, ADC_INPUT_A0, false);      //enable Sensor0 reading P5.5
    
            break;
    
        case Sensor1 :
            ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_EXTPOS_VREFNEG_EXTNEG, ADC_INPUT_A1, false);      //enable Sensor1 reading P5.4
    
            break;
    
        case Battery :
               ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_EXTPOS_VREFNEG_EXTNEG, ADC_INPUT_A2, false);      //enable Vbat reading P5.3
               
               break;
    
        case  Card1:
    
            ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_EXTPOS_VREFNEG_EXTNEG, ADC_INPUT_A22, false);      //enable BLE reading P8.3
    
            break;
    
        case Card2:
            ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_EXTPOS_VREFNEG_EXTNEG, ADC_INPUT_A19, false);      //enable NBIOT reading P8.6
    
            break;
    
            default :
    
            break;
        }
    
                ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);
                ADC14_enableInterrupt(ADC_INT0);
    
            /* Enabling Interrupts */
               Interrupt_enableInterrupt(INT_ADC14);
               Interrupt_enableMaster();
    
            /* Triggering the start of the sample */
               ADC14_enableConversion();
               ADC14_toggleConversionTrigger();
    
    
              // while (!(ADC14_getInterruptStatus() & ADC_INT0));
    
               Semaphore_pend(sem, BIOS_WAIT_FOREVER);
    
               return V_normalizedADCRes;
    
    }
    
    /* This interrupt happens whenever a conversion has been completed and placed
     * into ADC_MEM0. */
    void ADC14_IRQHandler(void)
    {
        uint64_t status;
        static volatile U32 V_RawData_u32r = 0;
        static volatile float v_TempData_U32r;
    
        status = ADC14_getEnabledInterruptStatus();
        ADC14_clearInterruptFlag(status);
        /* Disabling Conversion */
        ADC14_disableConversion();
    
        if(status & ADC_INT0)                        // when the ADC_MEM0 location finishes a conversion cycle, the ADC_INT0 interrupt will be set.
        {
            V_RawData_u32r = ADC14_getResult(ADC_MEM0);
            v_TempData_U32r = (V_RawData_u32r * 3.3f) / 16384;
    
        }
        V_normalizedADCRes = (int16) ((float)v_TempData_U32r * 1000.0); // convert V to mV
    
        Semaphore_post(sem);
    }
    

  • Hi,
    Above code is which I am using. same as TI ADC driverlib example code for ADC_external_ref.

    The problem is :
    1. ADC reads 1.868 Volt for a DC voltage of 1.65 V at its input in the case of Sensor 0.
    2. The same adc and same program reads 1.61V for an input DC voltage of 1.76 V for card 1. ADC output voltages were checked with JTAG debugger and voltages on circuit were tested with multimeter.

    Below is the program used for calculating the converted ADC value and it is running from a task in TI RTOS. External reference of 3.3 v is given to the circuit.

    Initialization of ADC is being done in MSP_EXP432P401R_initADC () function in MSP_EXP432P401R.c file.

    All these is being done because the TI RTOS APIs for ADC conversion were also returning the faulty values.

    I have tried using FPU, but the issue is same. I am not getting the cause of this error. Please help.
  • Is V_normalizedADCRes; declared volatile?

    There is no reason to make the variables in the ISR static volatile.
  • I marked it as answer by mistake. Yes, V_normalizedADCRes is declared as volatile.

**Attention** This is a public forum