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.

TM4C1294NCPDT: Can not get out of an interrupt process during ADC sample

Part Number: TM4C1294NCPDT

My program can not return the voltage value, value in expression window is  " identifier not found: ADC1_BASE"

and it seems like my program can not end a interrupt , the program is an basic example for ADC, I think it shouldn't act like this... 

  • Hi,

     The problem is the below line you have. You need to pass a pointer.

    ADCSequenceDataGet(ADC1_BASE, 0, ui32ADC1Value);

    You need to change to:

    ADCSequenceDataGet(ADC1_BASE, 0, &ui32ADC1Value);

    Below is a working code. 

    int main(void)
    {
        uint32_t ui32ADC1Value;
    
        SysCtlClockSet ( SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ ) ;
        SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
        GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2);
        ADCReferenceSet(ADC1_BASE, ADC_REF_INT);
        ADCSequenceConfigure(ADC1_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
        ADCSequenceStepConfigure(ADC1_BASE, 0, 0, ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END);
        ADCSequenceEnable(ADC1_BASE, 0);
        ADCIntClear(ADC1_BASE, 0);
    
        //volatile  uint32_t ui32ADC1Value;
    
    while(1)
    {
        ADCProcessorTrigger(ADC1_BASE, 0);
       while(!ADCIntStatus(ADC1_BASE, 0, false))
       {
       }
         ADCIntClear(ADC1_BASE, 0);
    
        //
        // Read ADC Value.
        //
        ADCSequenceDataGet(ADC1_BASE, 0, &ui32ADC1Value);
    
        SysCtlDelay(SysCtlClockGet() / 12);
    }
    }
    

  • Thanks for your help but I still have problem

    when I change the code I find the expression is still ''identifier not found: ui32ADC1Value'' when it start to run

    I wonder if there is something wrong with my equipment, but when I use the other device the same thing happened.

    when I click the resume, it looks like this

    when I click the suspend, it looks like this

    I do not have a DC power supply now so i connect the 3.3 V and PE2 to try ADC

    that's the code I used

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/adc.h"
    #include "driverlib/gpio.h"
    #include "driverlib/sysctl.h"
    int main(void)
    {
    uint32_t ui32ADC1Value;

    SysCtlClockSet ( SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ ) ;
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_2);
    ADCReferenceSet(ADC1_BASE, ADC_REF_INT);
    ADCSequenceConfigure(ADC1_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
    ADCSequenceStepConfigure(ADC1_BASE, 0, 0, ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END);
    ADCSequenceEnable(ADC1_BASE, 0);
    ADCIntClear(ADC1_BASE, 0);

    //volatile uint32_t ui32ADC1Value;

    while(1)
    {
    ADCProcessorTrigger(ADC1_BASE, 0);
    while(!ADCIntStatus(ADC1_BASE, 0, false))
    {
    }
    ADCIntClear(ADC1_BASE, 0);

    //
    // Read ADC Value.
    //
    ADCSequenceDataGet(ADC1_BASE, 0, &ui32ADC1Value);

    SysCtlDelay(SysCtlClockGet() / 12);
    }
    }

  • The code I gave you is for TM4C123. The clock definition for TM4C129 will be different. Therefore, you can first comment out the line so it just uses the internal PISOC by default just like what you had in your original code. 

      //SysCtlClockSet ( SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ ) ;  //comment out this line as this is for TM4C123

    Or define the clock for TM4C129 if you don't want to use PIOSC but rather PLL like below.
    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_240), 120000000);

    when I change the code I find the expression is still ''identifier not found: ui32ADC1Value'' when it start to run

    ui32ADC1Value is declared as a local variable. You cannot show it in expression windows. You can only view it in Variables. See below. If you want to see the variable in Expression window then you need to declare that variable as a global variable. Also you cannot display ADC1_BASE because it is merely a #define, not a expression.