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.
hi,各位ti的工程师们,请教一下在用adc12的时候调用内部基准源,但是功耗太大,不希望一直开着,如何关闭呢?
REFCTL0|=REFMSTR+REFVSEL_2;
REFCTL0 &= ~REFON; //关闭基准源
感觉只能在初始化中关闭,但是在后面再打开,发现打不开基准源;
REFCTL0 |= REFON; //打开基准源,发现不起作用;
我希望每次再调用ADC的时候再打开,不知道可行不?
芯片用的MSP430F5438A
感谢您的回复:
/*
ADC配置
*/
void ADC_Init(void)
{
P6SEL |= BIT5; //选择P6.5作为输入;
REFCTL0|=REFMSTR+REFVSEL_2; //使能REF管理,内部参考电压选择2.5v、打开内部参考电压
REFCTL0 &= ~REFON;
ADC12CTL0 = ADC12SHT02 + ADC12REF2_5V ;
ADC12CTL0 |= ADC12ON;
ADC12CTL1 = ADC12SHP; // 采样保持脉冲来自采样定时器
ADC12CTL2 |= ADC12TCOFF ; // 关闭内部内部温度检测以降低功耗,注意或操作否则修改转换精度
ADC12MCTL0= ADC12SREF_1+ADC12INCH_5; //选择参考电压源、现在a5通道
__delay_cycles(75);
ADC12CTL0 |= ADC12ENC; // ADC12使能
}
下面我用串口来调试,但是发现要连续输入9E两次才能关闭REF;
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
char temp;
switch(__even_in_range(UCA1IV,4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
while (!(UCA1IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
// UCA1TXBUF = UCA1RXBUF; // TX -> RXed character
temp = UCA1RXBUF;
if(temp == 0x8E)
{
REFCTL0 |= REFON;
}
if(temp == 0x9E )
{
REFCTL0 &= ~REFON;
}
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}
问题已解决,这样就好了:
if(temp == 0x8E)
{
ADC12CTL0 &= ~ADC12ENC;
REFCTL0 |= REFON;
ADC12CTL0 |= ADC12ENC;
}
if(temp == 0x9E )
{
ADC12CTL0 &= ~ADC12ENC;
REFCTL0 &= ~REFON;
}