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.

Increasing sampling rate of ADC module in Tiva Launchpad



Hi,

I am using Tiva C series launchpad for sampling 2 individual channels simultaneously. By default I am able to get only around 200,000 samples per second. How should I increase the sampling rate ?

I am using Tivaware APIs to develop the code. So is there any functions to change the sampling rate using some API ? 

Thanks in advance.

  • Hi!

    Can you please tell us in detail how exactly did you set up the ADC, what are you doing with the data and how exactly did you figure out the sample rate? Also system clock is important here. Code examples would be good.


    I've been struggling with ADCs on the Launchpad for a while now and based on my experience I suspect that it could be that the actual sample rate of the ADC is 1 MHz and that the main problem could be that there are other pieces of code which are slowing down re-triggering of the ADC. For example, just wiggling a pin using Tivaware API was for me often enough to significantly disturb the sample rate. If you're doing some processing before resetting the ADC, it could be the problem.

    To answer your explicit question: In new 2.1 Tivaware, you should use ADCClockConfigSet function to set the ADC clock rate.  Search the file called SW-TM4C-DRL-UG-2.1.0.12573.pdf in the docs directory of Tiwaware installation for the name of the function and you'll find the description.

    In the 2.0 Tivaware, you have function SysCtlADCSpeedSet and you can use it to set the sample rate of the ADC. The description is in file called SW-TM4C-DRL-UG-2.0.1.11577.pdf

    Do note that the default sample frequency is 1 MHz, so (if you're using the 123 Launchpad, which I assumed so far) you won't be able to increase the sample rate itself.

  • Hello Shyam,

    On TM4C123, you can get 1MSPS. But it seems that you are getting 200KSPS. How are you measuring the same?

    Also a code post (attachment preferred) would be useful.

    Regards

    Amit

  • Believe that responding poster Andreja makes many thoughtful, good points.  Surely your defense/explanation of your determination of the "real" ADC sample rate would be of interest.  (such is not trivial)

    Several quick/easy things always help:

    a) By employing SS0 - you harvest 8 "back to back" ADC readings at that sampling rate currently selected.  Any further ADC sampling is unlikely to begin again - immediately - thus maintaining that sampling rate "usually" is unobtainable when any normal/customary program load is placed upon the MCU.

    b) Both responders appear to have missed the potential "sample rate doubling" afforded by, "ADC Sample Phase Control!"  Your MCU manual - under ADC chapter - defines/details.

    c) The ADC is one of the peripherals which benefits greatly from the MCU's uDMA capability.  While complex - this uDMA usage and Sample Phase Control - in combination - should "squeeze the best ADC sample rate" from your device.

    Mixed signal ADC's (each/every maker) are supremely challenged @ their 3-4 least significant bits.  Should you "really" require fast & accurate ADC measurement - purpose built - ADC ICs exist for, "just that reason."  (kitchen sink MCU approach (i.e. use MCU as "beast of burden") saves cost/board size - but reality does intrude (performance degrades) - little in life is "free," w/out tradeoffs...)

  • To add to cb1's good ideas, I recently struggled with the ADC as well - this post (scroll to the bottom) has example code you could start from.

  • Thanks for that link, it's extremely related to my current interests!

  • Hi everyone,

    I am giving the complete code here. My requirement is to sample two ADC channels and display the waveform in a GLCD just like an oscilloscope.

    Andreja Kostic : The ADC setup and configuration is given in the code.

    Amit Ashara : This is the way I calculated that the sampling rate was 200 KSPS : since this is an oscilloscope program, I gave as sine wave as input to the channel with a particular frequency such that a single wave appears on the display which has 128 bits. That frequency was 1.63 kHz which means the time period is 625 us. So the time difference between two sampling would be (625us/128) which is 4.88 us. Hence the sampling rate would be 204 KSPS.

    cb1_mobile : I cannot use sequencer for back-to-back sampling because I need a variable delay between two samples.

    #include <stdbool.h>
    #include <stdint.h>
    #include "driverlib/adc.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom_map.h"
    #include "driverlib/sysctl.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "inc/hw_gpio.h"
    #include "KS0108.c"
    void PortFunctionInit(void){
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);							// Port A for control pins
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);							// Port B for data pins
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);							// For ADC pins
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);							// Port E for ADC inputs
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);							// Port F for LED lights
        SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);								// The ADC0 peripheral must be enabled for use.
        SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);								// The ADC1 peripheral must be enabled for use.
        GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_2);							// Configuring PD2 as ADC input (channel 1)		CH5
        GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_3);							// Configuring PD3 as ADC input (channel 2)		CH4
        GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0);							// Configuring PE0 as ADC input (time base)		CH3
        GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);}
    
    //Data port-PORTB	RS-PE1	RW-PE2	CS1-PE3	CS2-PE4
    
    int main(void)
    {
    	uint32_t i,adcbuffer[1];
    	uint8_t adc0data[128],adc1data[128];
    	uint8_t buf;
    	uint32_t timebase;
    	SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); //20 MHz clock
    	PortFunctionInit();
    	GLCD_Initalize();
    	GLCD_ClearScreen();
    
    	ADCSequenceConfigure(ADC0_BASE, 2, ADC_TRIGGER_PROCESSOR, 0);
    	ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
    	ADCSequenceConfigure(ADC1_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
    
    	ADCSequenceStepConfigure(ADC0_BASE, 2, 0, ADC_CTL_CH3 | ADC_CTL_IE | ADC_CTL_END);
    	ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH5 | ADC_CTL_IE | ADC_CTL_END);
    	ADCSequenceStepConfigure(ADC1_BASE, 3, 0, ADC_CTL_CH4 | ADC_CTL_IE | ADC_CTL_END);
    
    	ADCSequenceEnable(ADC0_BASE, 2);
    	ADCSequenceEnable(ADC0_BASE, 3);
    	ADCSequenceEnable(ADC1_BASE, 3);
    
    	ADCIntClear(ADC0_BASE, 2);
    	ADCIntClear(ADC0_BASE, 3);
    	ADCIntClear(ADC1_BASE, 3);
    
    	while(1)
    	{
    		ADCIntClear(ADC0_BASE, 2);
    		ADCProcessorTrigger(ADC0_BASE, 2);					// Trigger the ADC conversion.
    		while(!ADCIntStatus(ADC0_BASE, 2, false)){}			// Wait for conversion to be completed.
    		ADCIntClear(ADC0_BASE, 2);							// Clear the ADC interrupt flag.
    		ADCSequenceDataGet(ADC0_BASE, 3, &adcbuffer);		// Read ADC Value.
    		timebase = adcbuffer[0];
    		for (i=0;i<128;i++)
    		{
    			ADCIntClear(ADC0_BASE, 3);
    			ADCIntClear(ADC1_BASE, 3);
    			ADCProcessorTrigger(ADC1_BASE, (3|ADC_TRIGGER_WAIT));		// Put ADC-1 in Trigger Wait
    			ADCProcessorTrigger(ADC0_BASE, (3|ADC_TRIGGER_SIGNAL));		// Put ADC-0 in Global Trigger
    			while(!ADCIntStatus(ADC0_BASE, 3, false)){}					// Wait for conversion to be completed.
    			ADCIntClear(ADC0_BASE, 3);									// Clear the ADC interrupt flag.
    			ADCIntClear(ADC1_BASE, 3);									// Clear the ADC interrupt flag.
    			ADCSequenceDataGet(ADC0_BASE, 3, adcbuffer);				// Read ADC Value.
    			adc0data[i] = adcbuffer[0]/64;
    			ADCSequenceDataGet(ADC1_BASE, 3, adcbuffer);				// Read ADC Value.
    			adc1data[i] = adcbuffer[0]/64;
    		}
    		GLCD_ClearScreen();
    		for(i=64;i<128;i++)
    		{
    			GLCD_SetPixel(i,63-adc0data[i-64]);
    			GLCD_SetPixel(i,63-adc1data[i-64]);
    		}
    		for(i=0;i<63;i++)
    		{
    			GLCD_SetPixel(i,63-adc0data[i+64]);
    			GLCD_SetPixel(i,63-adc1data[i+64]);
    		}
    	}
    }
    

    In this program, I am able to display a waveform of frequency till 16 kHz clearly. But I need to display upto 50 kHz. I need a way to increase the sampling frequency. Also in the above program, in the line

    SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

    I have included the bit SYSCTL_10 which specifies a 20 MHz clock. In the tivaware document, it only specifies the various possibilities of that value like SYSCTL_1, SYSCTL_2, etc. but it does not specify the frequency which is will set. Please help me out in this.

    Thanks in advance.

  • Glad you responded - here my necessarily (biz appt. looms) quick comments.  (more later - if still sought/helpful)

    You state, "cb1_mobile : I cannot use sequencer for back-to-back sampling because I need a variable delay between two samples."  Might you be confusing the time-base of your Lcd Scope with the goal of achieving the highest possible data sampling rate?  (I think that you have!) 

    And - are you in compliance w/the Nyquist Sampling theorem?   Do you believe that these, higher sample rates must "fall victim" to your low-res scope's, "timebase?"  Again - I disagree w/your assertion that a variable delay is required between such samples.  Any such victimization of ADC bandwidth - to ease the creation of a display timebase - seems misguided.  Have not the "pro" scope makers long preached, "Convert as fast, and in ever increasing (stored) number - with the most accuracy?"  (you seem to think/believe, otherwise...)

    Central to your existing, "ADC speed up"  solution - I believe - lies in this "for loop":

    for (i=0;i<128;i++)
            {
                ADCIntClear(ADC0_BASE, 3);
                ADCIntClear(ADC1_BASE, 3);
                ADCProcessorTrigger(ADC1_BASE, (3|ADC_TRIGGER_WAIT));    // ADC-1 in Trigger Wait
                ADCProcessorTrigger(ADC0_BASE, (3|ADC_TRIGGER_SIGNAL));  // ADC-0 in Global Trigger
                while(!ADCIntStatus(ADC0_BASE, 3, false)){}              // Wait for conv to complete.
                ADCIntClear(ADC0_BASE, 3);                               // Clear ADC interrupt flag.
                ADCIntClear(ADC1_BASE, 3);                               // Clear ADC interrupt flag.
                ADCSequenceDataGet(ADC0_BASE, 3, adcbuffer);             // Read ADC Value.
                adc0data[i] = adcbuffer[0]/64;
                ADCSequenceDataGet(ADC1_BASE, 3, adcbuffer);             // Read ADC Value.
                adc1data[i] = adcbuffer[0]/64;
            }

    Above listing telegraphs that your display is 128x64 (tad pixel-sparse) for even a hobby O-Scope.  Earlier/higher up in your code - we learn that you control the time base via a pot - I'd think a series of "fixed values" (sequentially generated by momentary switch activation) would provide a more stable, more secure - scope timebase. (real scopes employ a multi-position, rotary switch - out of the question in your cost-down quest)

    My read of your code reveals that you hold your 2nd, "ADCSequenceDataGet()" hostage until you "scale" your ADC reading by 64.  That wastes time - should not be there!  Here's that code bit, again:

                ADCSequenceDataGet(ADC0_BASE, 3, adcbuffer);             // Read ADC Value. 
                adc0data[i] = adcbuffer[0]/64;                                                 // unwanted Traffic Cop & "pal" - 2 lines down!
                ADCSequenceDataGet(ADC1_BASE, 3, adcbuffer);

    Further - as you do this twice - and repeat this 128 times w/in that "for loop" - you've unnecessarily delayed the subsequent calls to your ADC - thus slowing (w/out any benefit) each/every one of your ADC's "back to back" reads.  Instead - perform that ADC scaling "outside of your critical "for loop" - (i.e. just prior to GLcd writes) when added time is less destructive to your design goals.  Your placement of that scaling code - right there, right then - does simplify your code - but at the cost of slowed ADC operation...  Q.E.D.

    Again - beyond this address of your code - your "forced" creation of any delay between ADC samples appears to, "fly in the face" of all ADC vendor's goal of, "faster, back to back, ADC operations!"  Rare to see this sacrificed to ease the creation of a, "time-base."

    Haven't used this vendor's M4 in awhile - suggest that you further review, "ADC_Trigger_Wait/Signal" - see if both are most appropriate for your, "high speed ahead" ADC application.

    And - for extra credit - switch to an Lcd with more standard controller, one with - "horizontal byte pixel organization."  In this way - when/while the input signal is constant - you write 8 pixels/(bits) in one shot - increasing your display update rate (potentially) by almost 8x.  (T-6963 is one such beast) 

    We note that you CLS your screen - and code presented shows no update of any normal/customary scope grid-lines - which most all serious scopes provide.  And - you can speed screen updates by writing first to a memory buffer - then more quickly/efficiently (via whole "byte writes" as opposed to your current "bit writes") transferring that buffer content to your screen...

    Some way/how - hallowed green Verify seems fitting/appropriate.  (user bias somewhat relaxed...)

  • Hi cb_1 mobile,

    I realize that the division inside the for loop slows down the ADC sampling rate. But I am facing another serious problem: if I do that division outside the for loop, I have to store the adcbuffer in a 16 bit variable instead of an 8 bit variable and it seems I cant store 256 different 16 bit variables. In the above code, I have declared three32 bit int and two 8 bit int arrays which totals to 256 words. If I declare adc1data and adc0data arrays as 16 bit int, the program is not executing.

    Moreover by declaring those 256 words as 8 bit int and doing the division outside the loop does not give me the 6 LS bits. Is there any other way of extracting the 6 LS bits without doing a division inside the for loop ?

  • Glad that you recognize that any "overload" of that "for loop" impedes that loop's execution rate.  Yet - you've further (I believe) unmet/unidentified issues. 

    Let's look at one quickly - you state, "...have to store adcbuffer in 16 bit var - instead of an 8 bit var."  Really - I don't think so!   Here's why - by your "divide by 64" - and in recognition of (4096 ADC vals accommodated w/in 12 bit ADC) don't you (sad to say) reduce the ADC's variable precision from 12 bits to (forgive me) just 6 bits?  (i.e. 4096/64 = 64) - thus you've "harvested" only 6 effective ADC bits!  Horrible as that seems - that's the max you can display on your, "pixel limited (128x64) Lcd.  (this explains why serious scopes usually employ 512 pixels {or beyond} as their vertical pixel minimum - yielding 9 bits of vertical ADC precision)  Thus - your use of a 16 bit variable to "accommodate" your, "6 resulting ADC bits" appears inefficient, unneeded.  With some thought - code experimentation - you should be able to pack 4 of these 6 bit readings w/in a single, 32 bit sram location.  After the ADC sequence (all 128 ADC "reads" in your case) you can easily, "process & unpack" that ADC data for transmission to your screen.

    You close your latest post w/ "declaring those 256 words as 8 bit int and doing the division outside the loop does not give me the 6 LS bits."  As I've detailed above - your LCD's 64 pixels (6 bits) is a major limiting factor - is it not?  Moving division, "outside the loop" as you assert - plays no bearing!    You "kill" those 6 lsb by your divide by 64 - and the when/where of that divide (mandated by your too small Lcd) is of no consequence.

    Your (resulting) 6 bit - Lcd pixel enforced - vertical resolution may not prove a deal-breaker.  At 3V3 max input - those 6 bits resolve to just over 50mV/bit.  (51.5mV on this bit worn/stained napkin)

    Clock's ticking on my, "reach 40K unrewarded forum points" prior to well earned travel/sail vacation.  You can do your part - if you wish - and reward time/effort/insight - focused quickly & repeatedly - your direction...

  • GETTING ERROR ON COMPILING THE CODE, KINDLY HELP SOMEBODY

    #include <stdbool.h>
    #include <stdint.h>
    #include "driverlib/adc.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom_map.h"
    #include "driverlib/sysctl.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "inc/hw_gpio.h"
    #include "inc/hw_ints.h"
    //#include "KS0108.c"
    void PortFunctionInit(void){
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // Port A for control pins
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // Port B for data pins
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); // For ADC pins
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // Port E for ADC inputs
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Port F for LED lights
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); // The ADC0 peripheral must be enabled for use.
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1); // The ADC1 peripheral must be enabled for use.
    GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_2); // Configuring PD2 as ADC input (channel 1) CH5
    GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_3); // Configuring PD3 as ADC input (channel 2) CH4
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0); // Configuring PE0 as ADC input (time base) CH3
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);}

    //Data port-PORTB RS-PE1 RW-PE2 CS1-PE3 CS2-PE4

    int main(void)
    {
    uint32_t i,adcbuffer[1];
    uint8_t adc0data[128],adc1data[128];
    uint8_t buf;
    uint32_t timebase;
    SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); //20 MHz clock
    PortFunctionInit();
    // GLCD_Initalize();
    // GLCD_ClearScreen();

    ADCSequenceConfigure(ADC0_BASE, 2, ADC_TRIGGER_PROCESSOR, 0);
    ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
    ADCSequenceConfigure(ADC1_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);

    ADCSequenceStepConfigure(ADC0_BASE, 2, 0, ADC_CTL_CH3 | ADC_CTL_IE | ADC_CTL_END);
    ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH5 | ADC_CTL_IE | ADC_CTL_END);
    ADCSequenceStepConfigure(ADC1_BASE, 3, 0, ADC_CTL_CH4 | ADC_CTL_IE | ADC_CTL_END);

    ADCSequenceEnable(ADC0_BASE, 2);
    ADCSequenceEnable(ADC0_BASE, 3);
    ADCSequenceEnable(ADC1_BASE, 3);
    ADCIntClear(ADC0_BASE, 2);
    ADCIntClear(ADC0_BASE, 3);
    ADCIntClear(ADC1_BASE, 3);

    while(1)
    {
    ADCIntClear(ADC0_BASE, 2);
    ADCProcessorTrigger(ADC0_BASE, 2); // Trigger the ADC conversion.
    while(!ADCIntStatus(ADC0_BASE, 2, false)){} // Wait for conversion to be completed.
    ADCIntClear(ADC0_BASE, 2); // Clear the ADC interrupt flag.
    ADCSequenceDataGet(ADC0_BASE, 3, &adcbuffer); // Read ADC Value.
    timebase = adcbuffer[0];
    for (i=0;i<128;i++)
    {
    ADCIntClear(ADC0_BASE, 3);
    ADCIntClear(ADC1_BASE, 3);
    ADCProcessorTrigger(ADC1_BASE, (3|ADC_TRIGGER_WAIT)); // Put ADC-1 in Trigger Wait
    ADCProcessorTrigger(ADC0_BASE, (3|ADC_TRIGGER_SIGNAL)); // Put ADC-0 in Global Trigger
    while(!ADCIntStatus(ADC0_BASE, 3, false)){} // Wait for conversion to be completed.
    ADCIntClear(ADC0_BASE, 3); // Clear the ADC interrupt flag.
    ADCIntClear(ADC1_BASE, 3); // Clear the ADC interrupt flag.
    ADCSequenceDataGet(ADC0_BASE, 3, adcbuffer); // Read ADC Value.
    adc0data[i] = adcbuffer[0]/64;
    ADCSequenceDataGet(ADC1_BASE, 3, adcbuffer); // Read ADC Value.
    adc1data[i] = adcbuffer[0]/64;
    }
    // GLCD_ClearScreen();
    /* for(i=64;i<128;i++)
    {
    GLCD_SetPixel(i,63-adc0data[i-64]);
    GLCD_SetPixel(i,63-adc1data[i-64]);
    }*/
    /* for(i=0;i<63;i++)
    {
    GLCD_SetPixel(i,63-adc0data[i+64]);
    GLCD_SetPixel(i,63-adc1data[i+64]);
    }*/
    }
    }

    ON COMPILING THE ABOVE CODE I AM GETTING ERROR AS KINDLY PLEASE HELP SOMEONE:-

    Rebuild target 'Target 1'
    compiling AnDC.c...
    AnDC.c(60): error: #167: argument of type "uint32_t (*)[1]" is incompatible with parameter of type "uint32_t *"
    ADCSequenceDataGet(ADC0_BASE, 3, &adcbuffer); // Read ADC Value.
    AnDC.c(31): warning: #550-D: variable "adc0data" was set but never used
    uint8_t adc0data[128],adc1data[128];
    AnDC.c(31): warning: #550-D: variable "adc1data" was set but never used
    uint8_t adc0data[128],adc1data[128];
    AnDC.c(32): warning: #177-D: variable "buf" was declared but never referenced
    uint8_t buf;
    AnDC.c(33): warning: #550-D: variable "timebase" was set but never used
    uint32_t timebase;
    AnDC.c: 4 warnings, 1 error
    assembling startup_TM4C123.s...
    ".\ADC.axf" - 1 Error(s), 4 Warning(s).
    Target not created

  • Shyam Sundhar G C said:
    I realize that the division inside the for loop slows down the ADC sampling rate.

    Division by 64 likely translates to a right shift (depends on the compiler) storing as 8 bits might actually be more time consuming on this architecture.

    Shyam Sundhar G C said:
    it seems I cant store 256 different 16 bit variables.

    I find that statement suspicious. That's only 10.5k. Significant but not overwhelming.

    Robert

    Wrong calc, I was thinking 32bits which may actually be faster. You would need to measure.

  • Hello Rajat

    ADCSequenceDataGet(ADC0_BASE, 3, &adcbuffer);

    Should be

    ADCSequenceDataGet(ADC0_BASE, 3, adcbuffer);
  • Thanks but still I am getting error as:-c

    Rebuild target 'Target 1'
    compiling AnDC.c...
    AnDC.c(35): warning: #550-D: variable "adc0data" was set but never used
    uint8_t adc0data[128],adc1data[128];
    AnDC.c(35): warning: #550-D: variable "adc1data" was set but never used
    uint8_t adc0data[128],adc1data[128];
    AnDC.c(37): warning: #550-D: variable "timebase" was set but never used
    uint32_t timebase;
    AnDC.c: 3 warnings, 0 errors
    assembling startup_TM4C123.s...
    linking...
    .\ADC.axf: Error: L6218E: Undefined symbol ADCIntClear (referred from andc.o).
    .\ADC.axf: Error: L6218E: Undefined symbol ADCIntStatus (referred from andc.o).
    .\ADC.axf: Error: L6218E: Undefined symbol ADCProcessorTrigger (referred from andc.o).
    .\ADC.axf: Error: L6218E: Undefined symbol ADCSequenceConfigure (referred from andc.o).
    .\ADC.axf: Error: L6218E: Undefined symbol ADCSequenceDataGet (referred from andc.o).
    .\ADC.axf: Error: L6218E: Undefined symbol ADCSequenceEnable (referred from andc.o).
    .\ADC.axf: Error: L6218E: Undefined symbol ADCSequenceStepConfigure (referred from andc.o).
    .\ADC.axf: Error: L6218E: Undefined symbol GPIOPinTypeADC (referred from andc.o).
    .\ADC.axf: Error: L6218E: Undefined symbol GPIOPinTypeGPIOOutput (referred from andc.o).
    .\ADC.axf: Error: L6218E: Undefined symbol SysCtlClockSet (referred from andc.o).
    .\ADC.axf: Error: L6218E: Undefined symbol SysCtlPeripheralEnable (referred from andc.o).
    .\ADC.axf: Error: L6218E: Undefined symbol SystemInit (referred from startup_tm4c123.o).
    Not enough information to list image symbols.
    Finished: 1 information, 0 warning and 12 error messages.
    ".\ADC.axf" - 12 Error(s), 3 Warning(s).
    Target not created

    & error is in the attached include file in lines 249 to 259 (error: unknown type name  'uint32_t')

    adc.h

    file is 

    //*****************************************************************************
    //
    // adc.h - ADC headers for using the ADC driver functions.
    //

    #ifndef __DRIVERLIB_ADC_H__
    #define __DRIVERLIB_ADC_H__

    //*****************************************************************************
    //
    // If building with a C++ compiler, make all of the definitions in this header
    // have a C binding.
    //
    //*****************************************************************************
    #ifdef __cplusplus
    extern "C"
    {
    #endif

    //*****************************************************************************
    //
    // Values that can be passed to ADCSequenceConfigure as the ui32Trigger
    // parameter.
    //
    //*****************************************************************************
    #define ADC_TRIGGER_PROCESSOR 0x00000000 // Processor event
    #define ADC_TRIGGER_COMP0 0x00000001 // Analog comparator 0 event
    #define ADC_TRIGGER_COMP1 0x00000002 // Analog comparator 1 event
    #define ADC_TRIGGER_COMP2 0x00000003 // Analog comparator 2 event
    #define ADC_TRIGGER_EXTERNAL 0x00000004 // External event
    #define ADC_TRIGGER_TIMER 0x00000005 // Timer event
    #define ADC_TRIGGER_PWM0 0x00000006 // PWM0 event
    #define ADC_TRIGGER_PWM1 0x00000007 // PWM1 event
    #define ADC_TRIGGER_PWM2 0x00000008 // PWM2 event
    #define ADC_TRIGGER_PWM3 0x00000009 // PWM3 event
    #define ADC_TRIGGER_NEVER 0x0000000E // Never Trigger
    #define ADC_TRIGGER_ALWAYS 0x0000000F // Always event
    #define ADC_TRIGGER_PWM_MOD0 0x00000000 // PWM triggers from PWM0
    #define ADC_TRIGGER_PWM_MOD1 0x00000010 // PWM triggers from PWM1

    //*****************************************************************************
    //
    // Values that can be passed to ADCSequenceStepConfigure as the ui32Config
    // parameter.
    //
    //*****************************************************************************
    #define ADC_CTL_TS 0x00000080 // Temperature sensor select
    #define ADC_CTL_IE 0x00000040 // Interrupt enable
    #define ADC_CTL_END 0x00000020 // Sequence end select
    #define ADC_CTL_D 0x00000010 // Differential select
    #define ADC_CTL_CH0 0x00000000 // Input channel 0
    #define ADC_CTL_CH1 0x00000001 // Input channel 1
    #define ADC_CTL_CH2 0x00000002 // Input channel 2
    #define ADC_CTL_CH3 0x00000003 // Input channel 3
    #define ADC_CTL_CH4 0x00000004 // Input channel 4
    #define ADC_CTL_CH5 0x00000005 // Input channel 5
    #define ADC_CTL_CH6 0x00000006 // Input channel 6
    #define ADC_CTL_CH7 0x00000007 // Input channel 7
    #define ADC_CTL_CH8 0x00000008 // Input channel 8
    #define ADC_CTL_CH9 0x00000009 // Input channel 9
    #define ADC_CTL_CH10 0x0000000A // Input channel 10
    #define ADC_CTL_CH11 0x0000000B // Input channel 11
    #define ADC_CTL_CH12 0x0000000C // Input channel 12
    #define ADC_CTL_CH13 0x0000000D // Input channel 13
    #define ADC_CTL_CH14 0x0000000E // Input channel 14
    #define ADC_CTL_CH15 0x0000000F // Input channel 15
    #define ADC_CTL_CH16 0x00000100 // Input channel 16
    #define ADC_CTL_CH17 0x00000101 // Input channel 17
    #define ADC_CTL_CH18 0x00000102 // Input channel 18
    #define ADC_CTL_CH19 0x00000103 // Input channel 19
    #define ADC_CTL_CH20 0x00000104 // Input channel 20
    #define ADC_CTL_CH21 0x00000105 // Input channel 21
    #define ADC_CTL_CH22 0x00000106 // Input channel 22
    #define ADC_CTL_CH23 0x00000107 // Input channel 23
    #define ADC_CTL_CMP0 0x00080000 // Select Comparator 0
    #define ADC_CTL_CMP1 0x00090000 // Select Comparator 1
    #define ADC_CTL_CMP2 0x000A0000 // Select Comparator 2
    #define ADC_CTL_CMP3 0x000B0000 // Select Comparator 3
    #define ADC_CTL_CMP4 0x000C0000 // Select Comparator 4
    #define ADC_CTL_CMP5 0x000D0000 // Select Comparator 5
    #define ADC_CTL_CMP6 0x000E0000 // Select Comparator 6
    #define ADC_CTL_CMP7 0x000F0000 // Select Comparator 7
    #define ADC_CTL_SHOLD_4 0x00000000 // Sample and hold 4 ADC clocks
    #define ADC_CTL_SHOLD_8 0x00200000 // Sample and hold 8 ADC clocks
    #define ADC_CTL_SHOLD_16 0x00400000 // Sample and hold 16 ADC clocks
    #define ADC_CTL_SHOLD_32 0x00600000 // Sample and hold 32 ADC clocks
    #define ADC_CTL_SHOLD_64 0x00800000 // Sample and hold 64 ADC clocks
    #define ADC_CTL_SHOLD_128 0x00A00000 // Sample and hold 128 ADC clocks
    #define ADC_CTL_SHOLD_256 0x00C00000 // Sample and hold 256 ADC clocks

    //*****************************************************************************
    //
    // Values that can be passed to ADCComparatorConfigure as part of the
    // ui32Config parameter.
    //
    //*****************************************************************************
    #define ADC_COMP_TRIG_NONE 0x00000000 // Trigger Disabled
    #define ADC_COMP_TRIG_LOW_ALWAYS \
    0x00001000 // Trigger Low Always
    #define ADC_COMP_TRIG_LOW_ONCE 0x00001100 // Trigger Low Once
    #define ADC_COMP_TRIG_LOW_HALWAYS \
    0x00001200 // Trigger Low Always (Hysteresis)
    #define ADC_COMP_TRIG_LOW_HONCE 0x00001300 // Trigger Low Once (Hysteresis)
    #define ADC_COMP_TRIG_MID_ALWAYS \
    0x00001400 // Trigger Mid Always
    #define ADC_COMP_TRIG_MID_ONCE 0x00001500 // Trigger Mid Once
    #define ADC_COMP_TRIG_HIGH_ALWAYS \
    0x00001C00 // Trigger High Always
    #define ADC_COMP_TRIG_HIGH_ONCE 0x00001D00 // Trigger High Once
    #define ADC_COMP_TRIG_HIGH_HALWAYS \
    0x00001E00 // Trigger High Always (Hysteresis)
    #define ADC_COMP_TRIG_HIGH_HONCE \
    0x00001F00 // Trigger High Once (Hysteresis)

    #define ADC_COMP_INT_NONE 0x00000000 // Interrupt Disabled
    #define ADC_COMP_INT_LOW_ALWAYS \
    0x00000010 // Interrupt Low Always
    #define ADC_COMP_INT_LOW_ONCE 0x00000011 // Interrupt Low Once
    #define ADC_COMP_INT_LOW_HALWAYS \
    0x00000012 // Interrupt Low Always
    // (Hysteresis)
    #define ADC_COMP_INT_LOW_HONCE 0x00000013 // Interrupt Low Once (Hysteresis)
    #define ADC_COMP_INT_MID_ALWAYS \
    0x00000014 // Interrupt Mid Always
    #define ADC_COMP_INT_MID_ONCE 0x00000015 // Interrupt Mid Once
    #define ADC_COMP_INT_HIGH_ALWAYS \
    0x0000001C // Interrupt High Always
    #define ADC_COMP_INT_HIGH_ONCE 0x0000001D // Interrupt High Once
    #define ADC_COMP_INT_HIGH_HALWAYS \
    0x0000001E // Interrupt High Always
    // (Hysteresis)
    #define ADC_COMP_INT_HIGH_HONCE \
    0x0000001F // Interrupt High Once (Hysteresis)

    //*****************************************************************************
    //
    // Values that can be used to modify the sequence number passed to
    // ADCProcessorTrigger in order to get cross-module synchronous processor
    // triggers.
    //
    //*****************************************************************************
    #define ADC_TRIGGER_WAIT 0x08000000 // Wait for the synchronous trigger
    #define ADC_TRIGGER_SIGNAL 0x80000000 // Signal the synchronous trigger

    //*****************************************************************************
    //
    // Values that can be passed to ADCPhaseDelaySet as the ui32Phase parameter and
    // returned from ADCPhaseDelayGet.
    //
    //*****************************************************************************
    #define ADC_PHASE_0 0x00000000 // 0 degrees
    #define ADC_PHASE_22_5 0x00000001 // 22.5 degrees
    #define ADC_PHASE_45 0x00000002 // 45 degrees
    #define ADC_PHASE_67_5 0x00000003 // 67.5 degrees
    #define ADC_PHASE_90 0x00000004 // 90 degrees
    #define ADC_PHASE_112_5 0x00000005 // 112.5 degrees
    #define ADC_PHASE_135 0x00000006 // 135 degrees
    #define ADC_PHASE_157_5 0x00000007 // 157.5 degrees
    #define ADC_PHASE_180 0x00000008 // 180 degrees
    #define ADC_PHASE_202_5 0x00000009 // 202.5 degrees
    #define ADC_PHASE_225 0x0000000A // 225 degrees
    #define ADC_PHASE_247_5 0x0000000B // 247.5 degrees
    #define ADC_PHASE_270 0x0000000C // 270 degrees
    #define ADC_PHASE_292_5 0x0000000D // 292.5 degrees
    #define ADC_PHASE_315 0x0000000E // 315 degrees
    #define ADC_PHASE_337_5 0x0000000F // 337.5 degrees

    //*****************************************************************************
    //
    // Values that can be passed to ADCReferenceSet as the ui32Ref parameter.
    //
    //*****************************************************************************
    #define ADC_REF_INT 0x00000000 // Internal reference
    #define ADC_REF_EXT_3V 0x00000001 // External 3V reference
    #define ADC_REF_EXT_1V 0x00000003 // External 1V reference

    //*****************************************************************************
    //
    // Values that can be passed to ADCIntDisableEx(), ADCIntEnableEx(),
    // ADCIntClearEx() and ADCIntStatusEx().
    //
    //*****************************************************************************
    #define ADC_INT_SS0 0x00000001
    #define ADC_INT_SS1 0x00000002
    #define ADC_INT_SS2 0x00000004
    #define ADC_INT_SS3 0x00000008
    #define ADC_INT_DMA_SS0 0x00000100
    #define ADC_INT_DMA_SS1 0x00000200
    #define ADC_INT_DMA_SS2 0x00000400
    #define ADC_INT_DMA_SS3 0x00000800
    #define ADC_INT_DCON_SS0 0x00010000
    #define ADC_INT_DCON_SS1 0x00020000
    #define ADC_INT_DCON_SS2 0x00040000
    #define ADC_INT_DCON_SS3 0x00080000

    //*****************************************************************************
    //
    // Values that can be passed to ADCClockConfigSet() and ADCClockConfigGet().
    //
    //*****************************************************************************
    #define ADC_CLOCK_RATE_FULL 0x00000070
    #define ADC_CLOCK_RATE_HALF 0x00000050
    #define ADC_CLOCK_RATE_FOURTH 0x00000030
    #define ADC_CLOCK_RATE_EIGHTH 0x00000010
    #define ADC_CLOCK_SRC_PLL 0x00000000
    #define ADC_CLOCK_SRC_PIOSC 0x00000001
    #define ADC_CLOCK_SRC_ALTCLK 0x00000001
    #define ADC_CLOCK_SRC_MOSC 0x00000002

    //*****************************************************************************
    //
    // Prototypes for the APIs.
    //
    //*****************************************************************************
    extern void ADCIntRegister(uint32_t ui32Base, uint32_t ui32SequenceNum,
    void (*pfnHandler)(void));
    extern void ADCIntUnregister(uint32_t ui32Base, uint32_t ui32SequenceNum);
    extern void ADCIntDisable(uint32_t ui32Base, uint32_t ui32SequenceNum);
    extern void ADCIntEnable(uint32_t ui32Base, uint32_t ui32SequenceNum);
    extern uint32_t ADCIntStatus(uint32_t ui32Base, uint32_t ui32SequenceNum,
    bool bMasked);
    extern void ADCIntClear(uint32_t ui32Base, uint32_t ui32SequenceNum);
    extern void ADCSequenceEnable(uint32_t ui32Base, uint32_t ui32SequenceNum);
    extern void ADCSequenceDisable(uint32_t ui32Base, uint32_t ui32SequenceNum);
    extern void ADCSequenceConfigure(uint32_t ui32Base, uint32_t ui32SequenceNum,
    uint32_t ui32Trigger, uint32_t ui32Priority);
    extern void ADCSequenceStepConfigure(uint32_t ui32Base,
    uint32_t ui32SequenceNum,
    uint32_t ui32Step, uint32_t ui32Config);
    extern int32_t ADCSequenceOverflow(uint32_t ui32Base,
    uint32_t ui32SequenceNum);
    extern void ADCSequenceOverflowClear(uint32_t ui32Base,
    uint32_t ui32SequenceNum);
    extern int32_t ADCSequenceUnderflow(uint32_t ui32Base,
    uint32_t ui32SequenceNum);
    extern void ADCSequenceUnderflowClear(uint32_t ui32Base,
    uint32_t ui32SequenceNum);
    extern int32_t ADCSequenceDataGet(uint32_t ui32Base, uint32_t ui32SequenceNum,uint32_t pui32Buffer);
    extern void ADCProcessorTrigger(uint32_t ui32Base, uint32_t ui32SequenceNum);
    extern void ADCSoftwareOversampleConfigure(uint32_t ui32Base,
    uint32_t ui32SequenceNum,
    uint32_t ui32Factor);
    extern void ADCSoftwareOversampleStepConfigure(uint32_t ui32Base,
    uint32_t ui32SequenceNum,
    uint32_t ui32Step,
    uint32_t ui32Config);
    extern void ADCSoftwareOversampleDataGet(uint32_t ui32Base,
    uint32_t ui32SequenceNum,
    uint32_t *pui32Buffer,
    uint32_t ui32Count);
    extern void ADCHardwareOversampleConfigure(uint32_t ui32Base,
    uint32_t ui32Factor);
    extern void ADCClockConfigSet(uint32_t ui32Base, uint32_t ui32Config,
    uint32_t ui32ClockDiv);
    extern uint32_t ADCClockConfigGet(uint32_t ui32Base, uint32_t *pui32ClockDiv);

    extern void ADCComparatorConfigure(uint32_t ui32Base, uint32_t ui32Comp,
    uint32_t ui32Config);
    extern void ADCComparatorRegionSet(uint32_t ui32Base, uint32_t ui32Comp,
    uint32_t ui32LowRef, uint32_t ui32HighRef);
    extern void ADCComparatorReset(uint32_t ui32Base, uint32_t ui32Comp,
    bool bTrigger, bool bInterrupt);
    extern void ADCComparatorIntDisable(uint32_t ui32Base,
    uint32_t ui32SequenceNum);
    extern void ADCComparatorIntEnable(uint32_t ui32Base,
    uint32_t ui32SequenceNum);
    extern uint32_t ADCComparatorIntStatus(uint32_t ui32Base);
    extern void ADCComparatorIntClear(uint32_t ui32Base, uint32_t ui32Status);
    extern void ADCIntDisableEx(uint32_t ui32Base, uint32_t ui32IntFlags);
    extern void ADCIntEnableEx(uint32_t ui32Base, uint32_t ui32IntFlags);
    extern uint32_t ADCIntStatusEx(uint32_t ui32Base, bool bMasked);
    extern void ADCIntClearEx(uint32_t ui32Base, uint32_t ui32IntFlags);
    extern void ADCSequenceDMAEnable(uint32_t ui32Base, uint32_t ui32SequenceNum);
    extern void ADCSequenceDMADisable(uint32_t ui32Base, uint32_t ui32SequenceNum);
    extern bool ADCBusy(uint32_t ui32Base);
    extern void ADCReferenceSet(uint32_t ui32Base, uint32_t ui32Ref);
    extern uint32_t ADCReferenceGet(uint32_t ui32Base);
    extern void ADCPhaseDelaySet(uint32_t ui32Base, uint32_t ui32Phase);
    extern uint32_t ADCPhaseDelayGet(uint32_t ui32Base);
    extern void ADCSampleRateSet(uint32_t ui32Base, uint32_t ui32ADCClock,
    uint32_t ui32Rate);
    extern uint32_t ADCSampleRateGet(uint32_t ui32Base);

    //*****************************************************************************
    //
    // Mark the end of the C bindings section for C++ compilers.
    //
    //*****************************************************************************
    #ifdef __cplusplus
    }
    #endif

    #endif // __DRIVERLIB_ADC_H__

  • Hello Rajat,

    That is because you have not added the driverlib precompiled library during the Linker phase so that the obj files can refer to the functions.
  • Thanks Amit,

    11 errors were resolved after adding driverlib.lib but still I am getting 1 error as followed:-

    Rebuild target 'Target 1'

    assembling startup_TM4C123.s...

    compiling _ADC3.c...

    _ADC3.c(90): warning:  #1-D: last line of file ends without a newline

     }

    _ADC3.c(32): warning:  #550-D: variable "adc0data" was set but never used

         uint8_t adc0data[128],adc1data[128];

    _ADC3.c(32): warning:  #550-D: variable "adc1data" was set but never used

         uint8_t adc0data[128],adc1data[128];

    _ADC3.c(33): warning:  #177-D: variable "buf" was declared but never referenced

         uint8_t buf;

    _ADC3.c(34): warning:  #550-D: variable "timebase" was set but never used

         uint32_t timebase;

    _ADC3.c: 5 warnings, 0 errors

    linking...

    .\_ADC3.axf: Error: L6218E: Undefined symbol SystemInit (referred from startup_tm4c123.o).

    Not enough information to list image symbols.

    Finished: 1 information, 0 warning and 1 error messages.

    ".\_ADC3.axf" - 1 Error(s), 5 Warning(s).

    Target not created

    Kindly help please

  • Thanks everybody to help

    on commenting below lines from startup_TM4c123.h all errors were resolved ,lines are

    ; IMPORT SystemInit


    ; LDR R0, =SystemInit
    ; BLX R0


  • Hello Rajat

    Glad all issues are resolved