我用的是easyarm615底板。编写程序实现如下的功能:使用adc的采样序列0,对0通道的模拟电压进行转换,转换完成后将数据存储,并点亮LED1指示数据存储完毕,然后熄灭,但是上电以后LED1一直亮,不知道原因。我用IAR,程序编好以后我点“debug“就会出现如下提示:could no find the source file:"c:cygwinhomekir chersanboxDriverlibuildDriverlib.PDL-LM3SDriverlib.testsrcadc.c",would you like to located you self? 程序如下: #include "hw_types.h" #include "hw_memmap.h" #include "hw_gpio.h" #include "hw_ints.h" #include "hw_adc.h" #include "sysctl.h" #include "gpio.h" #include "adc.h" #include "debug.h"
#define LED1 GPIO_PIN_7 #define KEY GPIO_PIN_4 void Go2Jtag(void)//防止jtag死锁 { SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); GPIODirModeSet(GPIO_PORTD_BASE,KEY,GPIO_DIR_MODE_IN); if(GPIOPinRead(GPIO_PORTD_BASE,KEY)==0) { while(1); } } void delay(int iCount) { for(;iCount;iCount--) { }; } unsigned long ulData;
int main(void) { Go2Jtag(); SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_6MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC); SysCtlADCSpeedSet(SYSCTL_ADCSPEED_125KSPS); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); GPIODirModeSet(GPIO_PORTD_BASE,LED1,GPIO_DIR_MODE_OUT);//配置LED1连接的GPIO口 ADCSequenceDisable(ADC_BASE,0); ADCSequenceConfigure(ADC_BASE,0,ADC_TRIGGER_PROCESSOR,0); ADCSequenceStepConfigure(ADC_BASE,0,0,ADC_CTL_CH0|ADC_CTL_END|ADC_CTL_IE); ADCSequenceEnable(ADC_BASE,0);//使能采样序列0 while(1) { ADCProcessorTrigger(ADC_BASE,0);//程序触发采样序列 while((HWREG(ADC_BASE+ADC_O_X_SSFSTAT)&0x00000100)); ADCSequenceDataGet(ADC_BASE,0,&ulData); ulData=(ulData*1000*3)/1024; GPIOPinWrite(GPIO_PORTD_BASE,LED1,~LED1);//如果采样完成,则LED1亮 delay(200000);//延长一段时间 GPIOPinWrite(GPIO_PORTD_BASE,LED1,LED1);//熄灭LED1 } }
|