求大神指导,怎么才能让程序从中断中出来,中断标志位应该不是在读取之后自动清除呀,可是我用仿真调试时,中断标志位一直是0x40,没有被清除,跪求解决方法。。。
#include
unsigned int Result[8]={0};
unsigned int Average=0;
void main(void)
{
WDTCTL = WDTPW+WDTHOLD;//关闭看门狗
P6SEL |= BIT6;
ADC12CTL0 = ADC12ON+ADC12SHT0_8+ADC12MSC; //打开ADC12,设置采样保持时间为256个ADC12时钟周期,多次采样转换位使能;
ADC12CTL1 |=ADC12CSTARTADD_6+ADC12SHP+ADC12CONSEQ_2;//使用第六通道,采样信号源自采样定时器,采样时间由采样定时器决定,单通道序列
ADC12MCTL6 |=ADC12INCH_6;//使用通道六
ADC12IE = BIT6; //打开相应通道中断
ADC12CTL0 |= ADC12ENC;//ADC12使能
ADC12CTL0 |= ADC12SC;//启动转换
P1DIR |=BIT0+BIT1;
P1OUT &=~BIT0;
while(1)
{
_bis_SR_register(LPM0_bits+GIE);
__no_operation();
}
}
#pragma vector=ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
static unsigned char index=0;
Result[index++]=ADC12MEM6; //存入转换结果
if(index==8)
{
unsigned char i;
for(i=0;i<8;i++)
Average +=Result;
Average>>=3;
index=0;
if(Average>=0x7f)
P1OUT =BIT0;
else
P1OUT &=~BIT0;
}
ADC12IFG =0X00;;
_bic_SR_register_on_exit(LPM0_bits);
}