"identifier not found" 在 C 中

"identifier not found" in C

我目前正在使用 C 语言的 Code Composer Studio 对微控制器(德州仪器的 TM4C123GH6PM)进行编程。为了测试代码,我想读出电阻上的电压。我已经编写了这段代码,并通过 TI 的示例对其进行了检查(这与我想要做的非常接近)。

这两种情况,编译代码都没有问题。但是,当我想查看表达式 ui32ADC0Value 时,Code Composer Studio 在启动代码 ui32ADC0Value = 0 之前显示 ui32ADC0Value 类型为 unsigned int,但在启动代码后它显示 "identifier not found" 并且类型突然变得未知。

我无法向我解释,因为正如我已经说过的,我尝试了一些与 TI 官方发布的代码非常相似的东西,但在这两种情况下都出现了错误。

这是我的代码:

#include<stdint.h>
#include<stdbool.h>
#include"inc/hw_ints.h"
#include"inc/hw_memmap.h"
#include"inc/hw_types.h"
#include"driverlib/gpio.h"
#include"driverlib/sysctl.h"
#include"driverlib/timer.h"
#include"driverlib/interrupt.h"
#include<math.h>
#include<driverlib/adc.h>
#include<driverlib/timer.h>


void main(void)
{
    uint32_t ui32ADC0Value;

    // set system clock
    SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);

    // activate ADC
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

    // assign ADC function to PIN PE2
    GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_2);

    // configure ADC
    ADCSequenceConfigure(ADC0_BASE,1,ADC_TRIGGER_PROCESSOR,0); // prozessor as trigger source
    ADCSequenceStepConfigure(ADC0_BASE,1,0,ADC_CTL_CH1|ADC_CTL_IE| ADC_CTL_END); // scan AI1 /generate interrupt at the end /last step
    ADCSequenceEnable(ADC0_BASE,1); // activate ADC Sequence 1

    while(1){
        ADCIntClear(ADC0_BASE,1); // delete maybe existing ADC Interrupts
        ADCProcessorTrigger(ADC0_BASE,1); // start convertion
        while(!ADCIntStatus(ADC0_BASE,1,false)){} // wait for end of convertion
        ADCSequenceDataGet(ADC0_BASE,1,&ui32ADC0Value); // read value
    }
}

感谢您提前帮助我。

优化的代码会使调试器难以知道如何跟踪您的变量值。尝试在禁用优化的情况下调试函数,或者在逐步跟踪函数调用点等处的值的同时观察反汇编

当我在 main 之外定义变量时,它起作用了。谢谢大家:)