AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINTs trigger at end of conversion
AdcRegs.INTSEL1N2.bit.INT1SEL = 6; //EOC6 triggers ADCINT1
设定为在SOC6转换完成产生ADCINT1中断
while (AdcRegs.ADCINTFLG.bit.ADCINT1 == 0){}
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Must clear ADCINT1 flag since INT1CONT = 0
Sum += AdcResult.ADCRESULT0;
Sum += AdcResult.ADCRESULT1;
Sum += AdcResult.ADCRESULT2;
Sum += AdcResult.ADCRESULT3;
Sum += AdcResult.ADCRESULT4;
Sum += AdcResult.ADCRESULT5;
Sum += AdcResult.ADCRESULT6;
Sum += AdcResult.ADCRESULT7;
CPU开始累加的时候在SOC6转换完成的时候,但是这个时候SOC7转换还未完成,此时进入累加操作会不会漏算SOC7的转换结果。为什么不直接将AdcRegs.INTSEL1N2.bit.INT1SEL = 6;语句中数据改为7,保证所有转换结果都被算入累加。
mou he:
回复 Eric Ma:
为什么不直接设定为EOC7时产生的中断开始累加;另:若主程序中设定了中断服务程序,AdcRegs.ADCINTFLGCLR.bit.ADCINT2 = 1语句是不是就可以移入中断服务程序中,现在的位置不用写。
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINTs trigger at end of conversion
AdcRegs.INTSEL1N2.bit.INT1SEL = 6; //EOC6 triggers ADCINT1
设定为在SOC6转换完成产生ADCINT1中断
while (AdcRegs.ADCINTFLG.bit.ADCINT1 == 0){}
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Must clear ADCINT1 flag since INT1CONT = 0
Sum += AdcResult.ADCRESULT0;
Sum += AdcResult.ADCRESULT1;
Sum += AdcResult.ADCRESULT2;
Sum += AdcResult.ADCRESULT3;
Sum += AdcResult.ADCRESULT4;
Sum += AdcResult.ADCRESULT5;
Sum += AdcResult.ADCRESULT6;
Sum += AdcResult.ADCRESULT7;
CPU开始累加的时候在SOC6转换完成的时候,但是这个时候SOC7转换还未完成,此时进入累加操作会不会漏算SOC7的转换结果。为什么不直接将AdcRegs.INTSEL1N2.bit.INT1SEL = 6;语句中数据改为7,保证所有转换结果都被算入累加。
Eric Ma:
回复 mou he:
如果放在中断,那在中断里就要对中断标志清除。
AdcRegs.ADCINTFLGCLR.bit.ADCINT2 = 1;
Eric
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINTs trigger at end of conversion
AdcRegs.INTSEL1N2.bit.INT1SEL = 6; //EOC6 triggers ADCINT1
设定为在SOC6转换完成产生ADCINT1中断
while (AdcRegs.ADCINTFLG.bit.ADCINT1 == 0){}
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Must clear ADCINT1 flag since INT1CONT = 0
Sum += AdcResult.ADCRESULT0;
Sum += AdcResult.ADCRESULT1;
Sum += AdcResult.ADCRESULT2;
Sum += AdcResult.ADCRESULT3;
Sum += AdcResult.ADCRESULT4;
Sum += AdcResult.ADCRESULT5;
Sum += AdcResult.ADCRESULT6;
Sum += AdcResult.ADCRESULT7;
CPU开始累加的时候在SOC6转换完成的时候,但是这个时候SOC7转换还未完成,此时进入累加操作会不会漏算SOC7的转换结果。为什么不直接将AdcRegs.INTSEL1N2.bit.INT1SEL = 6;语句中数据改为7,保证所有转换结果都被算入累加。
mou he:
回复 Eric Ma:
谢答主,大概搞清楚了