28035 ADC软件触发 采样不准是什么问题,采0V---ADC也有0~0.1V的变化。????????
InitAdc(); //
EALLOW;
// AdcRegs.ADCCTL1.bit.TEMPCONV = 1;
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; // //当转换结果存入结果寄存器时再开启ADC中断
//ADCSOCxCTL x可设置0--15,CHSEL 选择AD输入通道
AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; //set SOC0 channel select to ADCINA0 选择AD通道
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 1; //set SOC0 start trigger on software only 选择AD触发方式
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1) 配置转换时间
AdcRegs.ADCSOC1CTL.bit.CHSEL = 0; //set SOC0 channel select to ADCINA0 选择AD通道
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 1; //set SOC0 start trigger on software only 选择AD触发方式
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.INTSEL1N2.bit.INT1SEL = 1; //setup EOC0 to trigger ADCINT1 to fire;
AdcRegs.INTSEL1N2.bit.INT1E = 1; //Enabled ADCINT1;使能中断;
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; //禁止中断连续模式;
AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
AdcRegs.ADCINTSOCSEL1.bit.SOC1 = 1; //ADCINT1 will trigger SOC0. TRIGSEL field is ignored.
EDIS;
for(;;) //
{
AdcRegs.ADCSOCFRC1.all = 0x0F;
while (AdcRegs.ADCINTFLG.bit.ADCINT1== 0) ;
AdcRegs.ADCSOCFRC1.all = 0x00;
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
SampleTable[0] =AdcResult.ADCRESULT1 ;
USART_Transmit(SampleTable[0]>>8);
USART_Transmit(SampleTable[0]&0xff);
Delay_nMS(100);
GpioDataRegs.GPBTOGGLE.bit.GPIO43 = 1; // GPIO40端口电平翻转一次
}
先具体看一下寄存器ADCRESULT的值是多少,如果是基本稳定的,应该没什么大问题,可能是后面的计算不太恰当。
采集到的原始数据都是多少。模拟输入的0V,和单片机的地之间是真正0V吗。电源,参考电压是否都稳定。
模拟输入的0V; 电源,参考电压都稳定。寄存器ADCRESULT的值 在0x00~0x21之间变动.