请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:TM4C1294NCPDT Hi,
I'm doing some tests with EK-TM4C1294XL evaluation board using its ADC but the captured samples are too inaccurate, as you can see in the histogram bellow.
I would like to know what are your opinions about the possible reasons to this happening.
Bellow you can see the code I'm using and other related files.
The code is bellow :
#include #include include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/gpio.h" #include "driverlib/adc.h" #include "driverlib/interrupt.h" #include "driverlib/pin_map.h"#include "driveride_timers/idtidt.0001uidt_states #include "out_idt/idt.idt/idt.idt.0001u.idt/idt.0001u.000_0001u.idt/idt/idt_000u.idt/idt/idt_000u.idt_000u.void #include #include "out_0001u.idt_0001u.idt/idt/idt/idt/idt.000_000u.000u.h 、 void #include #include "out_000u.idt.000u.idt/idt.000u.idt. int main (void){ /*控制变量*/ State_t Current_state = SAMPLING; uint32_t amostra_ADC_0[1]; uint32_t 计数器= 0; //将时钟设置为以120MHz 运行*/ g_ui32SysClockSet (((sctl_XTAL_25MHz)| SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480)、120000000); ADC_INIT (); ConfigureTimer(); while (1){ switch (current_state){ case sampling: while (!ADCIntStatus (ADC0_BASE、3、false)); // Cleaning after astra Intar (ADC0_state*; disabling inceedsamples* = ADC100*;asure = ADC0 = ADC000_asure = ADC0、ADC000+;禁用 ADC100*= ADC0 = 当前值;ADC0 = ADC0;0 = ADC100*= ADC_ //问题就在这里!!!! SysCtlPeripheralDisable (SYSCTL_Periph_TIMER0); CURRENT_STATE = END_FLAG; break; case END_FLAG: //此处打开 LED 以标记结束 SysCtlEnable (SYSCTL_PERIPH_GPION); GPIOPINTypeGPIOOutput (GPIO_PORTn_BASE、GPIO_PINT_1 、GPIO_PORTn_PIN_1);GPIOP1_PIN_PIN_1引脚 GPIO_PIN_1); CURRENT_STATE = IDLE; break; case Idle: break; } 返回0; } void ADC_init (void){ //启用外设 ADC0 */ SysCtlPeripheralEnable (sysctl_Periph_ADC0); //启用端口 E 以读取 ADC0中的值*/ SysCtlPeripheralEnable (sys_Periph_ADC0 );//将 GPIO_PIN_PIN_0 (GP_0)引脚读取 GPIO_PIN_0 (0);// GPIO_PIN_PIN_PIN_0 (以读出 GPIO0* GPIO_PIN_PIN_PIN_PIN_PIN_PIN_PIN_0值 /*在 ADC0中配置采样序列3 */ ADCSequenceConfigure (ADC0_BASE,3, ADC_TRIGGER_PROCESSOR, 0); /*在 ADC0*/ ADCequenceStepConfigure 中配置步骤(ADC0_BASE,3, 0,(ADC_CTL_CH3 | ADCK_IE | ADC0*/ ADCK_BASE* ); / ADC0 (ADCK_ENABLE_BASE)*/ ADC0,启用 ADCK_ENABLE/ ADC0,ADCK_ENCH 0*中断*/ ADCK_ENABLE/ ADC0*;ADC0 (ADCK_ENCH)* 0) void Timer0ISR (void){ //清除全模式中计时器0模块的计时器中断*/ TimerIntClear (TIMER0_BASE、TIMER_TINA_TIMEOUT); ADCProcessorTrigger (ADC0_BASE、3); } void ConfigureTimer (void){ /*启用定时器0外设*/ SysCtlPeripheralEnable (SYSCTL_Periph_TIMER0); /*允许使用处理器中断*/ IntMasterEnable(); /*将计时器配置为使用32位周期计时器*/ TimerConfigure (TIMER0_BASE、TIMER_CFG_PERIODICASE); /*设置计时器加载值*/ //我们只使用计时器,因为我们需要32位计时器*/ /*这里我们有1ms */ TimerLoadSet (TIMER0_BASE、TIMER_A、g_ui32SysClock/1000); /*我们在这里将 ISR 设置为计时器0 */ TimerIntRegister (TIMER0_BASE、TIMER_A、Timer0ISR); /*允许定时器0中断*/ //我们只使用 timera,因为我们使用的是全带模式*/ IntEnable (INT_TIMER0A); /*在完全模式下启用 timer0中断*/ /*当出现超时情况时会出现*/ /*再次使用计时器 A,因为我们使用的是全屏模式*/ TimerIntEnable (TIMER0_BASE、TIMER_TINA_TIMEOUT); /*启用计时器*/ 计时器启用(TIMER0_BASE、TIMER_A); }