请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:EK-TM4C123GXL 工具/软件:Code Composer Studio
大家好、
我正在尝试使用 tm4c123gxl 读取模拟传感器。但我使用以下代码时遇到的问题是、当我尝试查看应存储 ADC 值的变量值时、表达式窗口中会显示"identifier not found"、 但是、如果在 while 循环之间的任意位置放置断点、变量的值将变为零。
#include #include #include "inc/hw_memmap.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/sysctl.h" #include "inc/hw_types.h" #include "driverlib/rom_map.h" #include "tintry"#include "mvoid.h"#include "t.mdg.h" SysCtlClockSet (SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHz); SysCtlPeripheralEnable (SYSCTL_Periph_ADC0); SysCtlPeripheralEnable (SYSCTL_Periph_GPIOE); GPIOPinTypeADC (GPIO_Porte _BASE、GPIO_PIN_3); ADCSequenceConfigure (ADC0_BASE、3、ADC_TRIGGER_PROCESSOR、0); ADCSequenceStepConfigure (ADC0_BASE、3、0、ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END); ADCSequenceEnable (ADC0_BASE、3); ADCIntClear (ADC0_BASE、3); volatile uint32_t ui32ADC0Value; while (1) { ADCProcessorTrigger (ADC0_BASE、3); while (!ADCIntStatus (ADC0_BASE、3、false) ){ } ADCIntClear (ADC0_BASE、3); // //读取 ADC 值。 // ADCSequenceDataGet (ADC0_BASE、3、ui32ADC0Value); SysCtlDelay (SysCtlClockGet ()/12); }