我采样的是一个模拟信号的A+和A-,(A+) 减去(A-)后的结果是实际模拟量的值,我采用同时采样模式。我希望初始化时用软件启动一次转换,之后通过ADCINT1触发连续执行ADC,可是程序只进一次ADC中断,后面就再也不进了,麻烦帮我看看问题在哪里。谢谢
初始化部分:
EALLOW;
AdcRegs.ADCCTL2.bit.ADCNONOVERLAP = 1; // Enable non-overlap mode
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; // INT pulse generation, 0=start of conversion, 1=end of conversion
AdcRegs.INTSEL1N2.bit.INT1E = 1; // Enabled ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; // Disable ADCINT1 Continuous mode
AdcRegs.INTSEL1N2.bit.INT1SEL = 1; //setup EOC1 to trigger ADCINT1 to fire
AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0 = 1;
AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; //set SOC0 channel select to ADCINA0 and ADCINB0
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 0; //set SOC0 start trigger on software
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 1; //ADCINT1 will trigger SOC0
AdcRegs.ADCSOCFRC1.bit.SOC0 = 1;
EDIS;
中断部分:
interrupt void adc_isr(void)
{
Voltage1[ConversionCount] = AdcResult.ADCRESULT0;
Voltage2[ConversionCount] = AdcResult.ADCRESULT1;
// If 20 conversions have been logged, start over
if(ConversionCount == 1)
{
ConversionCount = 0;
//GpioDataRegs.GPATOGGLE.bit.GPIO7 = 1;
}
else ConversionCount++;
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 flag reinitialize for next SOC
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE
return;
}
以上代码运行时,只进一次中断,但当我把AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 2; 时,每次都可进ADC中断,我不明白这是什么原因?本来想AdcRegs.ADCSOC0CTL.bit.TRIGSEL设置为ADCINT1触发,因为我认为要和AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 1; //ADCINT1 will trigger SOC0保持一致,可是设置里面没有ADCINT1触发这一项,所以我就试着选了TINT1n触发,没想到这样就可以进中断了。请问这是什么原因? 谢谢!
另外,AdcRegs.INTSEL1N2.bit.INT1SEL = 1; INT1SEL 这个位设置为0或者1,程序都能正常进中断,这是为什么?我个人理解设置为1才会产生ADCINT1中断,可是我设置为0照样可以进中断。请解释,谢谢啊!
gaoyang9992006:
那个软件包太大,我一时下载不完。你可以找到这个结构体原型的头文件,里面应该有对这个变量的说明,另外可以查看这个对应的变量在结构体中是占据多少个BIT。