本帖最后由 sdkxyx 于 2014-7-27 11:42 编辑
我使用M4的内部ADC采集两路数据,一个接地,一个接3V,使用序列0,采集到的数据放到一个8元素数组中。。采集到的值大小正常,但就是在数组中放置的顺序是随机的,完全没有规律。。不知道是哪里出了问题,希望了解的人帮忙解答下。。
下面是ADC的配置函数
- void ADCInit(void)
- {
- //多通道。。。。。
- SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
- SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
- GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_3|GPIO_PIN_2);
- ADCReferenceSet(ADC0_BASE,ADC_REF_INT);
- ADCSequenceConfigure(ADC0_BASE,SEQ_NUM,ADC_TRIGGER_TIMER,0);//每10us触发一次
- // ADCSequenceConfigure(ADC0_BASE,SEQ_NUM,ADC_TRIGGER_ALWAYS,0);
- // ADCSequenceConfigure(ADC0_BASE,SEQ_NUM,ADC_TRIGGER_PROCESSOR,0);
- ADCSoftwareOversampleConfigure(ADC0_BASE,SEQ_NUM,64);
- ADCSequenceStepConfigure(ADC0_BASE,SEQ_NUM,0,ADC_CTL_CH1);
- ADCSequenceStepConfigure(ADC0_BASE,SEQ_NUM,1,ADC_CTL_CH1);
- ADCSequenceStepConfigure(ADC0_BASE,SEQ_NUM,2,ADC_CTL_CH1);
- ADCSequenceStepConfigure(ADC0_BASE,SEQ_NUM,3,ADC_CTL_CH1);
- ADCSequenceStepConfigure(ADC0_BASE,SEQ_NUM,4,ADC_CTL_CH0);
- ADCSequenceStepConfigure(ADC0_BASE,SEQ_NUM,5,ADC_CTL_CH0);
- ADCSequenceStepConfigure(ADC0_BASE,SEQ_NUM,6,ADC_CTL_CH0);
- ADCSequenceStepConfigure(ADC0_BASE,SEQ_NUM,7,ADC_CTL_CH0| ADC_CTL_IE | ADC_CTL_END);
- ADCSequenceEnable(ADC0_BASE, SEQ_NUM);
- ADCIntRegister(ADC0_BASE,SEQ_NUM,ADC0IntHander);
- ADCIntClear(ADC0_BASE,SEQ_NUM);
- ADCIntEnable(ADC0_BASE,SEQ_NUM);
- }
复制代码下面是中断函数:
- void ADC0IntHander(void)
- {
- uint32_t temp[8] = {0};
- ADCSequenceDataGet(ADC0_BASE,SEQ_NUM,temp);
- ADCIntClear(ADC0_BASE,SEQ_NUM);//设置断点。。
- }
复制代码下面是每次运行至断点处采集到的数据:
感觉很奇怪,求解答:'(:'(:'(
一周热门 更多>