下面是初始化程序 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeGPIOInput(GPIO_PORTD_BASE,0XFF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC);
ADCReferenceSet(ADC_BASE,ADC_REF_INT);
SysCtlADCSpeedSet(SYSCTL_ADCSPEED_250KSPS);
ADCSequenceDisable(ADC_BASE,1);
ADCSequenceConfigure(ADC_BASE,1, ADC_TRIGGER_PROCESSOR,0);
ADCSequenceStepConfigure(ADC_BASE, 1, 0, ADC_CTL_CH12);
ADCSequenceStepConfigure(ADC_BASE, 1, 1, ADC_CTL_CH13);
ADCSequenceStepConfigure(ADC_BASE, 1, 2, ADC_CTL_CH14
|ADC_CTL_END
| ADC_CTL_IE);
ADCIntEnable(ADC_BASE, 1);
IntEnable(INT_ADC1);
IntMasterEnable();
ADCSequenceEnable(ADC_BASE,1);
unsigned int ADC_Sample()
{
unsigned int daLR,daLM,daMR,i;//三个传感器电压差值
ADCProcessorTrigger(ADC_BASE, 1);
while (!Flag);
Flag = 0;
ADCSequenceDataGet(ADC_BASE, 1, Value);
for (i = 0; i < 3; i++)
{
Value
= (Value * 3000) / 1024; // 转换成电压值
}
daLR=abs(Value[0]-Value[2]);
daLM=abs(Value[0]-Value[1]);
daMR=abs(Value[1]-Value[2]);
return( find_min(daLR,daLM,daMR));
}
采样的结果不管怎样全是0.是不是9B95又有什么特殊配置啊
此帖出自小平头技术问答
{
Value = (Value * 3000) / 1024; // 转换成电压值
}
这样可以吗
一周热门 更多>