请问MSP430F5438中,ADC12的中断函数中不能修改ADC12的配置吗?
我在ADC12中断函数中修改了ADC通道,然后就好像出不来了。
代码如下
void Init_ADC_A0_6432(void)
{
P6SEL = 0x01; // Enable A/D channel A0
P4OUT = 0X80;
ADC12CTL0 =0; //Disable conversion
ADC12CTL0 = ADC12ON+ADC12SHT0_8 ; // Turn on ADC12, set sampling time
ADC12CTL1 = ADC12SHP+ADC12CSTARTADD_0 ; // Use sampling timer,
ADC12CTL1 |= ADC12CONSEQ_0 + ADC12SSEL_2+ADC12DIV_0; // ADCCLK=MCLK,NO DIV
// ADC12CTL2 = ADC12RES_0; //8位的分辨率
ADC12MCTL0 = ADC12SREF_7+ADC12INCH_0; // ref+=AVcc(ext), channel = A0
// ADC12CTL1 = ADC12SHP+ADC12CONSEQ_2; // Use sampling timer, set mode
// ADC12IE = 0x0080; // Enable ADC12IFG.7
ADC12IE = 0x01; // Enable ADC12IFG.0
ADC12CTL0 |= ADC12ENC; // Enable conversions
}
void Init_ADC_A1_6432(void)
{
P6SEL = 0x02; // Enable A/D channel A0
P4OUT = 0X40;
ADC12CTL0 =0; //Disable conversion
ADC12CTL0 = ADC12ON+ADC12SHT0_8 ; // Turn on ADC12, set sampling time
ADC12CTL1 = ADC12SHP+ADC12CSTARTADD_0 ; // Use sampling timer,
ADC12CTL1 |= ADC12CONSEQ_0 + ADC12SSEL_2 +ADC12DIV_0; // ADCCLK=MCLK,NO DIV
ADC12CTL2 = ADC12RES_0; //8位的分辨率
ADC12MCTL0 = ADC12SREF_7+ADC12INCH_1; // ref+=AVcc(ext), channel = A0
// ADC12CTL1 = ADC12SHP+ADC12CONSEQ_2; // Use sampling timer, set mode
// ADC12IE = 0x0080; // Enable ADC12IFG.7
ADC12IE = 0x01; // Enable ADC12IFG.0
ADC12CTL0 |= ADC12ENC; // Enable conversions
}
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
char k,m,j=0,a=0,b=0,c=0,d=0;
switch(__even_in_range(ADC12IV,34))
{
case 0: break; // Vector 0: No interrupt
case 2: break; // Vector 2: ADC overflow
case 4: break; // Vector 4: ADC timing overflow
case 6: // Vector 6: ADC12IFG0
// Frame_scan_over = 1;
k = P7OUT&0x04; //查询选通SWITCH(k=1表示选通RX1-U2,否则选通RX2-U3)
if(k)
j = 0X0F-(P8OUT&0x0f); //取所处列数(左半屏)
else
j = 0x1F-((P8OUT>>4)&0x0f); //取所处列数(右半屏)
//判断所选TX
m = P4OUT;
switch(m)
{
case 0x80:
a = 0X0F-(P9OUT&0x0f);
if(a==15) //若已扫描到TX1末尾
{ //即1/4列扫描完毕
// P1OUT = 0xFF; //TX1置初值
P9OUT = 0xFF;
if(k)
{
if(j==15)
{ //停止RX1
P7OUT = 0X08; //选通RX2
P8OUT = 0XF0; //RX2置初值
}
else
P8OUT = P8OUT - 0x01 ;
}
else
{
if(j==31)
{
P7OUT = 0X04 ; //停止RX2,选通RX1
P8OUT = 0X0F ; //RX1置初值
Init_ADC_A1_6432();
}
else
P8OUT = P8OUT - 0x10 ;
}
}
else
{
// P1OUT -=0X11;
P9OUT -=0X01;
}
ADC_data[a][j] = 0xff-ADC12MEM0; //存储上1/4屏数据
if(Frame_scan_start==0)
{
// __delay_cycles(500) ;
ADC12CTL0 |= ADC12SC ; // Start sampling
}
break;
break;
default: break;
调试的时候,程序跑在
if(j==31)
{
P7OUT = 0X04 ; //停止RX2,选通RX1
P8OUT = 0X0F ; //RX1置初值
Init_ADC_A1_6432();
}
在这个位置设置断点,Init_ADC_A1_6432();
然后程序就停在这个重新设置ADC12的函数里了……
求指教