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.

TM4C123FH6PM: ADC Data Capture Question

Part Number: TM4C123FH6PM

Hello,

As for ADC, I didn't answer the previous question, so I created a new thread.

Below is the content

https://e2e.ti.com/support/microcontrollers/other/f/908/p/878416/3279617#3279617

Q1>  ADCSequenceDataGet (ADC1_BASE, 0, & pui32ADC0Value [0]) does not work properly.

       Please advise me.

Best Regards,

Jame,Shin

  • My friend,

    Had you considered that your "Linking the necessary background data" rather than "Presenting it (fresh) right here & now" - forces (both) "extra & disjointed" effort upon your hapless "helpers!"    Often - being forced to "Scroll Far Away ... and later return here" causes, "Loss of key facts - or (even) enables the "weakening & clouding" of an otherwise (powerful & helpful) method or idea...

    Indeed your "Time is important" - yet cannot the same be said of your helpers?    Can your "reduced effort" - which unfortunately "demands greater effort from your helpers" - be justified?    Is that wise?

  • Hi,

      I'm not sure why you are creating a new thread here. Normally you create a new thread if it is a new question. If this is an unanswered question from your previous thread then you should continue on that thread. When you create a new thread like this, I have to spend enormously amount of time to read  your other thread to understand the history and progress.

    Jame shin said:
    Q1>  ADCSequenceDataGet (ADC1_BASE, 0, & pui32ADC0Value [0]) does not work properly.

      What does it mean it does not work properly? Does it work sometime or does it not work at all? Can you just summarize what is wrong?

  • My justice friend, Cb1

    I'm not as fast as a rabbit (Ti and expert).

    It's hard, but it's just going late like a turtle.

    I have no right to compel them to answer. I’m do not justify

    I’m just wait for the touch of warmth.

    All I can do is walk in little by little. It's a wise choice.

    Best Regards,

    Jame,Shin

  • Hi Jame,

      I will want to help you. But you need to first tell me what is wrong with ADCSequenceDataGet (ADC1_BASE, 0, & pui32ADC0Value [0]). Does it not read the data or the data is not correct? Please elaborate the problem. 

  • Hello Charles,

    Thanks for you answer.

    I understood the regeneration thread note.

    Brief summary Question.

    How do I modify the source code?

    Q1> The values captured by the different ADCs cause problems with pui32ADC0Value [0] and pui32ADC1Value [0].

           So ADC1 does not work properly. I don't know why.

    Delay condition between ADCSequenceDataGet (ADC0_BASE,…) and ADCSequenceDataGet (ADC1_BASE,…) functions.

     //  PE[3]/AIN0(CH0), Volt -> ( ADC0 ) : +5V Measure,           

     //  PE[2]/AIN1(CH1), Volt -> ( ADC1 ) : +1.5V Measure

    (No delay)

         pui32ADC0Value[0] ADC Calculated Value : 4.54V

         pui32ADC1Value[0] ADC Calculated Value : 4.54V

    (1’s delay)

         pui32ADC0Value[0] ADC Calculated Value : 4.54V (5V-4.5V=0.5V)

         pui32ADC1Value[0] ADC Calculated Value :0.26V (1.5-0.26 =1.24V )

    Q2> The 64Pin TQFP MCU supplied ADC VREFP 3.3V.

               The DK-EVB 144Pin MCU is VREFP 3.0V. This difference results in 0.5V difference in ADC0 measurement

               How can I calibrate 0.5V?

    Best Regards,

    Jame,Shin

    Main( ) 
    {
       char pcVoltBuffer1[6];
       char pcCurrBuffer1[6];
       char pcVoltBuffer2[6];
       char pcCurrBuffer2[6]  
          ……
       uint32_t pui32ADC0Value[2]; 
       uint32_t pui32ADC1Value[2];
         ……
       uint32_t ui32Volt;
       uint32_t ui32Current;
         ……
       SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
       SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
    
       SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
       SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD)
    
       GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3|GPIO_PIN_2);       
       GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_1|GPIO_PIN_0); 
    
       ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);   
       ADCSequenceConfigure(ADC1_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
    
       ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH0|ADC_CTL_CH6|ADC_CTL_IE|ADC_CTL_END);
       ADCSequenceStepConfigure(ADC1_BASE, 0, 2, ADC_CTL_CH1|ADC_CTL_CH7|ADC_CTL_IE|ADC_CTL_END);
    
       ADCSequenceEnable(ADC0_BASE, 0);
       ADCSequenceEnable(ADC1_BASE, 0);
    
       IntMasterEnable();
    
    
      while(1)
      {
          …….
          ADCProcessorTrigger(ADC0_BASE, 0);
          ADCProcessorTrigger(ADC1_BASE, 0);
    
           while(!ADCIntStatus(ADC0_BASE, 0, false) && !ADCIntStatus(ADC1_BASE, 0, false) )
           {
            }
          ADCIntClear(ADC0_BASE, 0);
          ADCIntClear(ADC1_BASE, 0)
    
           // PE[3]/AIN0(CH0), Volt -> ( ADC0 )
           ADCSequenceDataGet(ADC0_BASE, 0, &pui32ADC0Value[0]);
    
           ui32Volt=(pui32ADC0Value[0]* 4100) / 819;
           usnprintf(pcVoltBuffer, 5, "%u.%u ", ui32Volt/1000,ui32Volt%1000);
    
           // PD[1]/AIN6(CH6), Curr -> (ADC0)
           ui32Current = (pui32ADC0Value[1] * 200) / 273;
           usnprintf(pcCurrBuffer, 5, "%u.%04u ", ui32Current/1000,ui32Current%1000);
            .....
    
           // PE[2]/AIN1(CH1), Volt -> ( ADC1 )
           ADCSequenceDataGet(ADC1_BASE, 0, &pui32ADC1Value[0]); 
    	
           ui32Volt=(pui32ADC1Value[0]* 4100) / 819;   
           usnprintf(pcVoltBuffer, 5, "%u.%u ", ui32Volt/1000,ui32Volt%1000);
           
           // PD[0]/AIN7(CH7), Curr -> ( ADC1 )
           ui32Current = (pui32ADC1Value[1] * 200) / 273;
           usnprintf(pcCurrBuffer, 5, "%u.%04u ", ui32Current/1000,ui32Current%1000);
           ......
    
        }
    }
    

  • Let's look at the below few lines of code first. How do you know pui32ADC0Value[1] has the correct data? When you call ADCSequenceDataGet it will return the number of samples copped to the buffer. You need to base on the number of data copied to the buffer to determine if there is valid data in the pui32ADC0Value[1] or even pui32ADC0Value[0]. 

    // PE[3]/AIN0(CH0), Volt -> ( ADC0 )
           ADCSequenceDataGet(ADC0_BASE, 0, &pui32ADC0Value[0]);
           ui32Volt=(pui32ADC0Value[0]* 4100) / 819;
           usnprintf(pcVoltBuffer, 5, "%u.%u ", ui32Volt/1000,ui32Volt%1000);
           // PD[1]/AIN6(CH6), Curr -> (ADC0)
           ui32Current = (pui32ADC0Value[1] * 200) / 273;
           usnprintf(pcCurrBuffer, 5, "%u.%04u ", ui32Current/1000,ui32Current%1000);

    4.2.2.28 ADCSequenceDataGet


    Gets the captured data for a sample sequence.


    Prototype:
    int32_t
    ADCSequenceDataGet(uint32_t ui32Base,
    uint32_t ui32SequenceNum,
    uint32_t *pui32Buffer)


    Parameters:
    ui32Base is the base address of the ADC module.
    ui32SequenceNum is the sample sequence number.
    pui32Buffer is the address where the data is stored.


    Description:
    This function copies data from the specified sample sequencer output FIFO to a memory resident
    buffer. The number of samples available in the hardware FIFO are copied into the buffer,
    which is assumed to be large enough to hold that many samples. This function only returns

    the samples that are presently available, which may not be the entire sample sequence if it is
    in the process of being executed.


    Returns:
    Returns the number of samples copied to the buffer.

  • Hello again Charles,

    Well presented - young staff & I appreciate your analysis.

    Months past - this (frequent) poster appeared to "buy into" KISS and its "High Focus, & Simplification Safeguards."   Both now appear to have, "Left the building..."

    As you say - let's look (further) at those few lines of poster code:

    // PE[3]/AIN0(CH0), Volt -> ( ADC0 )
           ADCSequenceDataGet(ADC0_BASE, 0, &pui32ADC0Value[0]);
           ui32Volt=(pui32ADC0Value[0]* 4100) / 819;
           usnprintf(pcVoltBuffer, 5, "%u.%u ", ui32Volt/1000,ui32Volt%1000);
           // PD[1]/AIN6(CH6), Curr -> (ADC0)
           ui32Current = (pui32ADC0Value[1] * 200) / 273;
           usnprintf(pcCurrBuffer, 5, "%u.%04u ", ui32Current/1000,ui32Current%1000);
     
    Note that there exists (ONLY) one line of "Focused, ADC Module Code!"   (all code in highlight - strays from what should be poster's "Central ADC Module Focus" - thus diverts poster's attention!)
     
    Is it not possible that, "Beyond that huge diversion" (4:1 code lines) there may be "mistakes" w/in poster's "Non-Direct ADC Code?"    And that's not "Fair to you - or (other) of his helpers!"
     
    Should it not  be noted that, "Poster attempts to Solve Everything" - too often results in, "Solving Nothing!"   It is believed that higher (i.e. proper) FOCUS - will strengthen poster's MCU programming abilities...
     
    Poster's (proper) noting of the "RAW ADC Values attained" - rather than their "Modified/Scaled/otherwise Processed Values" - would lessen the possibility of (outside) "Non-ADC" coding errors - while "Reducing the (excess) demands" placed upon helpers.    Assisting the "helpers" should "rise to prime consideration" - by "help-seekers."