TI中文支持网
TI专业的中文技术问题搜集分享网站

关于TM4C1294XL ADC

配置ADC  代码如下,单步的时候查看ui32ACCValues里的值,只有三个在变化,是我哪里配置错误了吗? 
 
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_16MHZ |SYSCTL_OSC_MAIN |SYSCTL_USE_PLL |SYSCTL_CFG_VCO_480), 120000000);ui32PWMClock = ui32SysClkFreq / 64;//配置ADC
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0| GPIO_PIN_1 | GPIO_PIN_2);
	GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
	ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 4, ADC_CTL_CH7);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 5, ADC_CTL_CH6);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 6, ADC_CTL_CH5);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH3);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_CH2);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_CH1|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, ui32ACCValues);
	}

long he1:

没有人么。。。。

long he1:

来人啊!帮帮忙啊!

xyz549040622:

回复 long he1:

光看例程的话,该配置的都配置完了,具体你ADC不启动

1.查看官方给的例程,看看ADC初始化过程中你配置的先后顺序,TIVA系列对这个很敏感的,初始化顺序错了也有影响

2.单独调试,跟踪寄存器看看,哪个寄存器没初始化OK呢

xyz549040622:

回复 long he1:

给你个可以用的例程

//模数转换器实验程序解析
//头文件
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/fpu.h"
#include "driverlib/sysctl.h"
#include "driverlib/rom.h"
#include "driverlib/pin_map.h"
#include "grlib/grlib.h"
#include "drivers/cfal96x64x16.h"
#include "driverlib/gpio.h"
#include "driverlib/adc.h"
#include "inc/hw_gpio.h"int main(void)
{tContext sContext;tRectangle sRect;ui32 ulADC0_Value;ui8 ulADC0_v[8];ui32 i,j;const char chars[16]={"0123456789ABCDEF"};//使能FPUFPUEnable();FPULazyStackingEnable();//设置系统时钟为50MHz (400/2/4=50)ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL |SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);//初始化ADC0/PE3ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);ROM_GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);//设置ADC参考电压为外部3VROM_ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V);//配置ADC采集序列ROM_ADCSequenceConfigure(ADC0_BASE, 0,ADC_TRIGGER_PROCESSOR, 0);ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0 |ADC_CTL_END | ADC_CTL_IE);//使能ADC采集序列ROM_ADCSequenceEnable(ADC0_BASE, 0);ROM_ADCIntClear(ADC0_BASE, 0);ROM_ADCIntEnable(ADC0_BASE, 0);//初始化显示模块CFAL96x64x16Init();GrContextInit(&sContext, &g_sCFAL96x64x16);while(1){//触发采集ADCProcessorTrigger(ADC0_BASE, 0);//等待采集结束while(!ADCIntStatus(ADC0_BASE, 0, false)) ;//获取采集结果ADCSequenceDataGet(ADC0_BASE, 0, &ulADC0_Value);//将采集结果从32位无符号数转化为chari=28;for(j=0;j<8;j++){ulADC0_v[j]=chars[(ulADC0_Value>>i)&0xf];i-=4;}//延时SysCtlDelay(SysCtlClockGet() / 12);//屏幕的上面24行填充蓝色覆盖上次的显示结果sRect.i16XMin = 0;sRect.i16YMin = 0;sRect.i16XMax = GrContextDpyWidthGet(&sContext) - 1;sRect.i16YMax = 23;GrContextForegroundSet(&sContext, ClrDarkKhaki);GrRectFill(&sContext, &sRect);//在颜色块的边缘放置白框GrContextForegroundSet(&sContext, ClrWhite);GrRectDraw(&sContext, &sRect);//显示工程名称和采集结果GrContextFontSet(&sContext, g_psFontCm12);GrStringDrawCentered(&sContext, ulADC0_v, 8,GrContextDpyWidthGet(&sContext) / 2, 10, 0);GrStringDrawCentered(&sContext, "ADC Results", -1,GrContextDpyWidthGet(&sContext) / 2,((GrContextDpyHeightGet(&sContext) - 24) / 2) + 24, 0);//更新显示GrFlush(&sContext);}
}

赞(0)
未经允许不得转载:TI中文支持网 » 关于TM4C1294XL ADC
分享到: 更多 (0)