I run the program in FLASH program sampling frequency 20K, there are always dozens per AD numerical point of collection errors, led me to set the enable flag malfunction, which is why I ask
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I run the program in FLASH program sampling frequency 20K, there are always dozens per AD numerical point of collection errors, led me to set the enable flag malfunction, which is why I ask
source file is:
void adcpeizhi()//adc初始化配置
{
Uint16 i;
//定义ADC时钟
EALLOW;
SysCtrlRegs.HISPCP.all = 0x3; // HSPCLK=SYSCLOCK/2/3=25M
EDIS;
AdcRegs.ADCTRL1.bit.ACQ_PS = 0x0; // S/Hclk = 1/ACQ_PS+1)/1/25=12.5m
InitAdc(); //初始化ADC
AdcRegs.ADCTRL3.bit.ADCCLKPS = 0; //不分频
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1; // SEQ1和SEQ2联合起来作为一个十六位的排序器
AdcRegs.ADCTRL1.bit.SEQ_OVRD = 1; //存储结果连续覆盖
AdcRegs.ADCTRL1.bit.CONT_RUN = 1; //设置为连续转换模式
AdcRegs.ADCMAXCONV.bit.MAX_CONV1=0x1;
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x8; //ADCINB0
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x9; //ADCINB1
//数组清零
for(i=0;i<2;i++)
{
AdcTable[i] = 0;
}
}
void adccaiji()//adc采集
{
AdcRegs.ADCTRL2.all = 0x2000;//启动ADC,SOC_SEQ1=1;
while(AdcRegs.ADCST.bit.INT_SEQ1 == 0){}
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1; //清除SEQ1中断标志位
AdcTable[0]= (AdcRegs.ADCRESULT0>>4);
AdcTable[1]= (AdcRegs.ADCRESULT1>>4);
AdcRegs.ADCST.bit.INT_SEQ1_CLR=1; //清除SEQ1中断标志位
dianya=(AdcTable[0]/1365.3333+0.15)*13.877;
dianliu=(AdcTable[1]/170.666)-18.64;
//GpioDataRegs.GPBTOGGLE.bit.GPIO61=1;
if(dianya>=31) {start_pwm++;}
//if(start_pwm>8){start_pwm=8;}
//start_pwm++;
}