int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // 停止看门狗
// clock_config(); // 初始化时钟
adc12_config(); // 初始化ADC12
uart_config(); //初始化UART
TA1CCTL0 = CCIE; // 使能TA1CCR0,比较匹配中断
TA1CCR0 = 1092; // 初始化最大值,发生比较匹配中断频率 32768/32768 = 1Hz
TA1CTL = TASSEL_1 + MC_1 + TACLR; // 选择ACLK,最大值为CCR0,清除计数值
_EINT(); // 初始化全局中断
P1DIR = BIT0|BIT1; //控制LED1,2 输出
P8SEL &= 0xFE;
P8DIR |= BIT0;
P8OUT &= 0xFE; //IC9 en 拉低输出2.8V供电
P7SEL &= 0xFB;
P7DIR |=BIT2;
P7OUT |=BIT2; //p7.2 驱动放大器使能
P4SEL = 0x00;
P4DIR |= BIT0|BIT1|BIT2|BIT3|BIT4|BIT5|BIT6;
P4OUT = 0x20;//使能IO,驱动几个芯片的
P7OUT &= 0xFB;
P4OUT &= 0xF9;
__delay_cycles(5000);
P4OUT |= 0x06;
// __delay_cycles(1000);
// P4OUT &= 0xF9;
// __delay_cycles(5000);
// P4OUT |= 0x04;
// __delay_cycles(1000);
// P4OUT &= 0xF9;
// SelectChannel(0);
while(1)
{
switch(channelset)
{
case 0:
SelectChannel(0);
while ( !(ADC12IFG & BIT0) ); // 等待转换完成
ADC_DATA = ADC12MEM0;
XZhou_LOW = (ADC_DATA &0x00ff);
XZhou_HIG = (ADC_DATA &0xff00) >> 8;
++channelset;
break;
case 1:
SelectChannel(1);
while ( !(ADC12IFG & BIT0) ); // 等待转换完成
ADC_DATA = ADC12MEM0;
YZhou_LOW = (ADC_DATA &0x00ff);
YZhou_HIG = (ADC_DATA &0xff00) >> 8;
++channelset;
++channelset;
break;
case 2:
break;
case 3:
SelectChannel(3);
while ( !(ADC12IFG & BIT0) ); // 等待转换完成
ADC_DATA = ADC12MEM0;
ZZhou_LOW = (ADC_DATA &0x00ff);
ZZhou_HIG = (ADC_DATA &0xff00) >> 8;
channelset = 0;
break;
default:
break;
}
if(second_flag)
{
second_flag = 0;
tx_buf[0] = 0xAA;
tx_buf[1] = XZhou_LOW;
tx_buf[2] = XZhou_HIG;
tx_buf[3] = YZhou_LOW;
tx_buf[4] = YZhou_HIG;
tx_buf[5] = ZZhou_LOW;
tx_buf[6] = ZZhou_HIG;
tx_buf[7] = 0xBB;
tx_buf[8] = crc_xor(tx_buf,8);
uart_send(tx_buf,9);
}
__bis_SR_register(LPM4_bits + GIE); // Enter LPM4, Enable interrupts
__no_operation(); // For debugger
}
}
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void)
{
second_flag = 1;
__bic_SR_register_on_exit(LPM4_bits); // Enter LPM3 每隔30毫秒1次
}
程序如上,去掉
__bis_SR_register(LPM4_bits + GIE); // Enter LPM4, Enable interrupts
__no_operation(); // For debugger
__bic_SR_register_on_exit(LPM4_bits); // Enter LPM3 每隔30毫秒1次
这三句话,程序正常运行,电流大概在8.6MA,可以采集到实时数据,并每隔30毫秒串口发出,
但是,加入低功耗,AD采集数据一直不变,且三组数据都是一样的一组,低功耗也没降下电流还是8.6MA请问怎么回事呢?急急~~~~~~~~
|