问题:下载程序后只能进行一次AD转换 调节所测电压不会改变显示 重新下载程序后会改变数值 求解 不知是哪个配置出了问题
while(1)
{
//AdcRegs.ADCTRL2.all = 0x4000; //reset
//AdcRegs.ADCTRL2.all = 0x2000; //software begin
adc_set( );
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1
AdcRegs.ADCTRL2.bit.SOC_SEQ1=1;
display(result*3.0/4096.0);
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;
delay();
}
}
void adc_set(void )
{
InitAdc(); // For this example, init the ADC
AdcRegs.ADCTRL1.bit.ACQ_PS = 0x01;
AdcRegs.ADCTRL3.bit.ADCCLKPS = 0x3;
AdcRegs.ADCTRL1.bit.SEQ_CASC = 0; // 1 Cascaded mode
AdcRegs.ADCTRL1.bit.CONT_RUN=1;
AdcRegs.ADCTRL1.bit.SEQ_OVRD=1;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x04;
// Setup continuous run
// Step 5. User specific code, enable interrupts:
// Start SEQ1
AdcRegs.ADCTRL2.all = 0x2800; //software begin
while (AdcRegs.ADCST.bit.INT_SEQ1== 0) { } // Wait for interrupt
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;
result =((AdcRegs.ADCRESULT0>>4) );
//display(result*3.3/4096.0);
AdcRegs.ADCTRL1.bit.RESET = 1;
} |