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.

TM4C123GH6PM: Problem with ADC

Part Number: TM4C123GH6PM

#define PWM_FREQUENCY 55

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/pwm.h"
#include "driverlib/adc.h"
uint32_t sysclock;
uint32_t input_value;
uint32_t i;
int sample_val[100],pinVal,pinVal1;
extern  uint32_t ulADC0Value[100];




//PG1 is the PWM Pin
void main()
{

 // 600KHz Signal on    PE5

  //  float PWM_FREQ;
  //  float CPU_FREQ;
  //  float pwm_word;



  //  PWM_FREQ = 1434; //
   // CPU_FREQ = 120000000;
   // pwm_word = (1/PWM_FREQ)*CPU_FREQ;
    //sysclock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN |SYSCTL_USE_PLL |SYSCTL_CFG_VCO_480), CPU_FREQ);


    SysCtlPWMClockSet(SYSCTL_PWMDIV_64);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    GPIOPinTypePWM(GPIO_PORTE_BASE, GPIO_PIN_5);
    GPIOPinConfigure(GPIO_PE5_M0PWM5);
    PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_DB_NO_SYNC);
    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, 200); //Setting for 200KHz
    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 200); // 50% Duty Cycle
    PWMGenEnable(PWM0_BASE, PWM_GEN_2);
    PWMOutputState(PWM0_BASE, PWM_OUT_5_BIT, true);

    uint32_t PWMClock = SysCtlClockGet() / 64;
    uint32_t Load = (PWMClock / PWM_FREQUENCY) - 1;

    PWMGenPeriodSet(PWM1_BASE, PWM_GEN_0, Load);
     //while(1){}




    //ADC Sampling on PE3

      SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);


       GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);


        SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
        ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 266);
        ADCSequenceDisable(ADC0_BASE, 1);

        ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PWM0*3, 0);
        ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH0);
        ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_CH0);
        ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_CH0);
        ADCSequenceStepConfigure(ADC0_BASE, 1, 3, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
                   ADCSequenceEnable(ADC0_BASE, 1);

                   while(1)
                   {
                                 ADCIntClear(ADC0_BASE, 1);
                                 ADCProcessorTrigger(ADC0_BASE, 1);

                                 while(!ADCIntStatus(ADC0_BASE, 1, false))
                                 {


                                 }

                                 ADCSequenceDataGet(ADC0_BASE, 1, &ulADC0Value[100]);
                                // uint32_t pinVal; // variable to hold the pinRead
                                 pinVal= GPIOPinRead(GPIO_PORTE_BASE,GPIO_PIN_3);
                                pinVal1= GPIOPinRead(GPIO_PORTE_BASE,GPIO_PIN_4);
                                 int a=0;

                                 for ( a=1;a<=1; a++){

                              uint32_t res=a;

                                 }




/*for (i=0;i<100;i++){
int a=GPIOPinRead(GPIO_PORTE_BASE,GPIO_PIN_3);

uint32_t adc_val[]=
}*/

}

}


I am getting errors, which I don't understaand and I unable to understand.

Description    Resource    Path    Location    Type
#10010 null: errors encountered during linking; "ADC_Sampling2.out" not built    ADC_Sampling2             C/C++ Problem
<a href="processors.wiki.ti.com/.../10234"> null: unresolved symbols remain    ADC_Sampling2             C/C++ Problem
gmake: *** [ADC_Sampling2.out] Error 1    ADC_Sampling2             C/C++ Problem
gmake: Target 'all' not remade because of errors.    ADC_Sampling2             C/C++ Problem
unresolved symbol ulADC0Value, first referenced in ./project.obj    ADC_Sampling2             C/C++ Problem

  • You declared the variable ulADC0Value as external, but then never defined it. If you just delete the "extern" keyword, your code will compile and link. If you later need to reference that array externally, you need both the declaration and the definition.

    extern  uint32_t ulADC0Value[100];
    uint32_t ulADC0Value[100];
    

    The first line declares the label external so it can be referenced from different files. The second actually causes the compiler/linker to allocate the storage. You can have many .c files that have the "extern" line, but only one .c file that actually creates the variable.