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.

Tiva C Series TM4C1294 Connected LaunchPad - ADC

Other Parts Discussed in Thread: LM35

Hi All,

I would like to interface 4 Temperature Sensor to the TM4C1294 Launchpad , unfortunately  Tivaware does not contains any ADC examples so please guide me to start working on it.

Thanks,

Ashok r

  • asokfair said:
    I would like to interface 4 Temperature Sensor to the TM4C1294 Launchpad

    What temperature sensors do you want to interface to TM4C1294 Launchpad? Provide a link to those Temperature Sensors.

    asokfair said:
    unfortunately  Tivaware does not contains any ADC examples so please guide me to start working on it.

     See, ADC examples at this Tivaware folder location, "\\examples\peripherals\adc". There are also ADC code example at Tivaware Peripheral Library User's Guide.\

    - kel

  • Hi,

    Here are some more examples for Tiva in general:

    http://forum.stellarisiti.com/forum/37-code-vault/

  • Thank you! both

    I am now trying to integrate ADC into the blinky Led example , i included the following paths,

    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "inc/hw_adc.h"
    #include "driverlib/debug.h"
    #include "driverlib/adc.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/rom.h"
    #include "driverlib/rom_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "driverlib/udma.h"
    #include "driverlib/gpio.h"

    int
    main(void)
    {
        uint32_t ui32SysClock;
        uint32_t ui32adcValues[2], ui32Count;

       
        SysCtlDelay(10);
    }

    if i compile the above program i am getting error


    #10010 errors encountered during linking; "blinky.out" not built    blinky             C/C++ Problem
    <a href="file:/c:/ti/ccsv6/tools/compiler/dmed/HTML/10234.html">

    #10234-D</a>  unresolved symbols remain    blinky             C/C++ Problem
    unresolved symbol SysCtlDelay, first referenced in ./blinky.obj    blinky             C/C++ Problem

    i could not resolve it. i believe its missing some configuration   or linker directory

    Thanks,

    Ashok r

  • Hi,

       Blinky example does not have driverlib included. Use other examples like "hello", then append your code to it.

       What temperature sensors do you want to interface to TM4C194 Launchpad. Provide a link to those temperature sensors.

    - kel

  • Hi Kel,

    I am going to use LM35  http://www.ti.com/product/lm35  , Total 4 Sensors  so i need 4 Channels of ADC

    Thanks,

    Ashok r

  • Hi,

    I have here how i create a project. And also how i use a generic start project to create new projects by importing the generic one. (Remember this is how i create it and it works, i can be not the best)

    https://sites.google.com/site/luiselectronicprojects/tutorials/create-a-tiva-project

  • Thanks Luis,

    here below my ADC config its working fine for 1 channel. (PE3)

    SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOE);
            SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
            SysCtlPeripheralReset(SYSCTL_PERIPH_ADC0);
            SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
            SysCtlDelay(10);

            GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0 );

            ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_EIGHTH, 30);

                // Choose Sequencer 2 and set it at the highest Priority.
            ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_ALWAYS, 0);

                // Choose Step 0 in Sequencer 2 as Data Buffer, set it as last Step and enable Interrupts
            ADCSequenceStepConfigure(ADC0_BASE,0,0, ADC_CTL_CH0);
            ADCSequenceStepConfigure(ADC0_BASE,0,1, ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END);

            ADCSequenceEnable(ADC0_BASE, 0);

    now i want to add three more channels. (PE0,PE1,PE2) how do i can change this above code?

  • Hello Asokfair,

    The above code would get modified as

            ADCSequenceStepConfigure(ADC0_BASE,0,0, ADC_CTL_CH0);
            ADCSequenceStepConfigure(ADC0_BASE,0,1, ADC_CTL_CH1);

            ADCSequenceStepConfigure(ADC0_BASE,0,2, ADC_CTL_CH2);

            ADCSequenceStepConfigure(ADC0_BASE,0,3, ADC_CTL_CH3 | ADC_CTL_IE | ADC_CTL_END);

    When the interrupt comes or the Status Polling indicates that conversion is complete then you have to read 4 units of ADC Data. The order of the data will be channel0,1,2 and 3

    Regards

    Amit

  • Hi Amit,

    when i modified the code like above you mentioned , its reading only the CH1 values , other 3 channel values not updating. pls refer the attached picture.

    My ADC Reading function is given below,

    uint32_t
    WaitAndReadADC(uint32_t *adcValues)
    {

        ADCProcessorTrigger(ADC0_BASE,0);
        // Wait until the sample sequence has completed.

        while(!ADCIntStatus(ADC0_BASE, 0, false)) { }
        // Read the value from the ADC.


        return(ADCSequenceDataGet(ADC0_BASE, 0, adcValues));
    }

    my doubt is , anything i need to modify here? " 0"

  • Hello Ashok,

    What you have done is correct and needs no modification. Did you try changing the voltage value on the 4 pins and then check if the values read in the array after ADC conversion do change?

    Regards

    Amit

  • Yes Amit,


    I am changing the voltage values , 0 and 3.3v  in all PE0,PE1,PE2 and PE3 pins but it changes the value in adcValues[0]  none of other are not changing the value

    my doubt is this following ADC Read Call with 0 is correct for reading CH1 ,CH2,CH3 values?

    ADCSequenceDataGet(ADC0_BASE, 0, adcValues)


    because in qs_iot example project , the internal temperature is reading by using sequence number 3

    also it has  different configuration like ADC_TRIGGER_PROCESSOR  is used instead of the Always Trigger

    ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_ALWAYS,  0);

    let me know if you needs any additional inputs

    Thanks,

    Ashok r

  • Hello Ashok,

    Do you want to read the Internal Temperature Sensor or an external voltage?

    As I mentioned earlier, the command is correct for the Sequencer-0.

    Regards

    Amit

  • Hi Amit,

    I want to read external temperature.

    Yes if i use only one Channel , the working perfectly but when i want use multi channel like  CH0 (temp1), CH1(temp2), CH2(temp3) and CH3(temp4) its not working. 

    I want to read the voltage across the 4 Channels pins (PE0,PE1,PE2,PE3)

    Thanks,

    Ashok r

  • Hello Ashok,

    Please send in the main code that you have as an attachment.

    Regards

    Amit

  • Yeah , Please find here attachment

    1541.hello.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    //*****************************************************************************
    //
    // hello.c - Simple hello world example.
    //
    // Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved.
    // Software License Agreement
    //
    // Texas Instruments (TI) is supplying this software for use solely and
    // exclusively on TI's microcontroller products. The software is owned by
    // TI and/or its suppliers, and is protected under applicable copyright
    // laws. You may not combine this software with "viral" open-source
    // software in order to form a larger program.
    //
    // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
    // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
    // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
    // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
    // DAMAGES, FOR ANY REASON WHATSOEVER.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Thanks,

    Ashok r

  • Hello Ashok,

    I tested the code on my DK-TM4C129 by connecting one-by-one PE0, PE1, PE2 and PE3 to 3.3V and remaining to GND.

    Also the ALWAYS_TRIGGER and the PROCESSOR_TRIGGER don't go hand in hand since the Always trigger will cause a trigger to occur all the time and when you use the variable window the data will shift as the sampler is working but the CCS has halted the CPU

    New Code as below:

    5037.TM4C129_ADCMultiChannel.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    //*****************************************************************************
    //
    // hello.c - Simple hello world example.
    //
    // Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved.
    // Software License Agreement
    //
    // Texas Instruments (TI) is supplying this software for use solely and
    // exclusively on TI's microcontroller products. The software is owned by
    // TI and/or its suppliers, and is protected under applicable copyright
    // laws. You may not combine this software with "viral" open-source
    // software in order to form a larger program.
    //
    // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
    // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
    // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
    // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
    // DAMAGES, FOR ANY REASON WHATSOEVER.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Attached is the snapshot of the Memory Window and it reads fine.

    Regards

    Amit

  • Thanks Amit !

    It works !

  • Hello Ashok,

    So what was the problem when it did not work. Elaborating that would be good for the forum knowledge base.

    Regards

    Amit

  • Hi Amit,


    The problem is , ADC sequence was not configured properly in the below code.

        ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_ALWAYS,  0);

    ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_ALWAYS,  0);

            ADCSequenceConfigure(ADC0_BASE, 2, ADC_TRIGGER_ALWAYS,  0);

            ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_ALWAYS,  0);

     

     

    Thanks,

    Ashok r

  • Hello Ashok,

    Please note that the Priority of the Sequencers cannot be the same. They are graded. So in case you put all of them to the same priority the default order of 0.1.2.3 will happen.

    Regards
    Amit