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.

MSPM0L1105: Read ADCs and GPIOs values issues

Part Number: MSPM0L1105

mspm0l1105_fw_ccs.zip

Dear Ti team,

We have many read values issues, please help to check how to fix them.
The source project has been attached.

As you can see in source code, we have 8 adc channels to read and also 8 gpio (called PX_nFLT, X=0,1,2,…) to read (by i2c).
But so far it’s strange for some cases:
1. Read Gpio all 0
From our HW design, if corresponding adc have values, GPIO should be 1, too.
But what we read is all 0 even some adc got values.
2. ADC read value not correct
When I plug in port3, and I can read adc3 got values, it’s right.
But adc7 also show values even I don’t plug in anything to port7, and HW measurement is also 0.

Could you help to direct us how to check these issues?

Thanks!

  • Hi, 

    1. Read Gpio all 0

    Are you using LaunchPad? Make sure GPIO is right set and connected, please refer to LP's schematic: https://www.ti.com/lit/pdf/slau869

    If not, please check these pin manually by pull these pin to 3.3V or GND.

    P2_nFLT is a output pin in syscfg.

    2. ADC read value not correct

    What is these abnormal values? Some small noise is normal.

    Also, try to test these ADC input manually pull to 3.3V or GND.

    Regards,

    Helic

  • Hi Helic,

    ADC read value incorrect coming from our ADC 8 channels reading. The reading result result[4] is equal to result[0], result[5] is equal to result[1]....etc. Could you help to review our code and check if somewhere having errors.

     

    Thanks! 

  • Hi, 

    2. ADC read value not correct

    you need to enable and start conversion after you change the ADC channel configuration.

    For ADC conversion with channel switch, you should follow this logic:

        while (1) {
    
            // Configure MEM0-3 channels to original settings
            DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_0,
               DL_ADC12_INPUT_CHAN_1, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED, // MEM0, ADC channel 1
               DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
            DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_1,
               DL_ADC12_INPUT_CHAN_0, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED, // MEM1, ADC channel 0
               DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
            DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_2,
               DL_ADC12_INPUT_CHAN_9, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED, // MEM2, ADC channel 9
               DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
            DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_3,
               DL_ADC12_INPUT_CHAN_8, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED, // MEM3, ADC channel 8
               DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
    
            //Enable ADC conversion
            DL_ADC12_enableConversions(ADC12_0_INST);
            //Start ADC conversion
            DL_ADC12_startConversion(ADC12_0_INST);
    
            /* Wait until all data channels have been loaded. */
            while (gCheckADC == false) {
                __WFE();
            }
            gCheckADC = false;
    
            /* Store ADC Results into their respective buffer */
            gAdcResult[0] = DL_ADC12_getMemResult(ADC12_0_INST, DL_ADC12_MEM_IDX_0);
            gAdcResult[1] = DL_ADC12_getMemResult(ADC12_0_INST, DL_ADC12_MEM_IDX_1);
            gAdcResult[2] = DL_ADC12_getMemResult(ADC12_0_INST, DL_ADC12_MEM_IDX_2);
            gAdcResult[3] = DL_ADC12_getMemResult(ADC12_0_INST, DL_ADC12_MEM_IDX_3);
    
            // Reconfigure MEM0-3 to different channels
            DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_0,
               DL_ADC12_INPUT_CHAN_5, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,  // MEM0, ADC channel 5
               DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
            DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_1,
               DL_ADC12_INPUT_CHAN_4, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,  // MEM1, ADC channel 4
               DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
            DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_2,
               DL_ADC12_INPUT_CHAN_3, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED, // MEM2, ADC channel 3
               DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
            DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_3,
               DL_ADC12_INPUT_CHAN_2, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED, // MEM3, ADC channel 2
               DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
               
            //Enable ADC conversion
            DL_ADC12_enableConversions(ADC12_0_INST);
            //Start ADC conversion
            DL_ADC12_startConversion(ADC12_0_INST);
    
            /* Second pass. Wait until all data channels have been loaded. */
            while (gCheckADC == false) {
                __WFE();
            }
            gCheckADC = false;
    
            /* Store ADC Results into their respective buffer */
            gAdcResult[4] = DL_ADC12_getMemResult(ADC12_0_INST, DL_ADC12_MEM_IDX_0);
            gAdcResult[5] = DL_ADC12_getMemResult(ADC12_0_INST, DL_ADC12_MEM_IDX_1);
            gAdcResult[6] = DL_ADC12_getMemResult(ADC12_0_INST, DL_ADC12_MEM_IDX_2);
            gAdcResult[7] = DL_ADC12_getMemResult(ADC12_0_INST, DL_ADC12_MEM_IDX_3);
        }
        
        
        
    /* Check for the last result to be loaded then change boolean */
    void ADC12_0_INST_IRQHandler(void)
    {
        switch (DL_ADC12_getPendingInterrupt(ADC12_0_INST)) {
            case DL_ADC12_IIDX_MEM3_RESULT_LOADED:
                gCheckADC = true;
                break;
            default:
                break;
        }
    }

    In single main while(1) loop,

    Configrue ADC channel to setting 1, and start conversion waiting for result, store the result to RAM.

    then re-configure another set of ADC channel, then Start ADC again and waiting for the result.

    Regards,

    Helic