int main(void)
{
//WDTCTL = WDTPW | WDTHOLD;
WDTCTL = WDTPW+WDTCNTCL+WDTSSEL0+WDTIS2;//复位时间 1s
SYS_Init();
SYSCFG0 = FRWPPW|DFWP;
restart++;
SYSCFG0 = FRWPPW|PFWP | DFWP;
while(1)
{
TA0R = Timer0Cunt;
//使能Timer0//////////
TA0CCR0 = 16384;
TA0CTL = TASSEL_1 | MC__UP; // ACLK, UP mode
TA0CCTL0 |= CCIE; // TACCR0 interrupt enabled
//////////////////////
tmp_count++;
Comm_Process(); //通讯处理
Error_Check();
MeterDateWrite();
//关闭Timer0//////////
TA0CCTL0 = 0;
TA0CTL = 0;
TA0CCR0 =0;
//////////////////////
Timer0Cunt = TA0R;
WDTCTL = WDTPW | WDTHOLD;
__bis_SR_register(LPM4_bits|GIE); // Enter LPM
__no_operation(); // For debugger
}
}
#pragma vector=PORT2_VECTOR
__interrupt void Port_2 (void)
{
Pluse_Cont();
WDTCTL = WDTPW+WDTCNTCL+WDTSSEL0+WDTIS2;//复位时间 1s
__bic_SR_register_on_exit(LPM4_bits); // Exit LPM0 on reti
}
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
UART_Rece();
WDTCTL = WDTPW+WDTCNTCL+WDTSSEL0+WDTIS2;//复位时间 1s
__bic_SR_register_on_exit(LPM4_bits); // Exit LPM0 on reti
}
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
{
tmp_count1++;
WDTCTL = WDTPW+WDTCNTCL+WDTSSEL1+WDTIS2;
}
求大神知道怎么降低功耗
此帖出自
小平头技术问答
{
P1DIR = 0xFF;P1OUT = 0x00;
P2DIR = 0xFF;P2OUT = 0x00;
P3DIR = 0xFF;P3OUT = 0x00;
P2DIR &=~(S1I+S2I+DTI); //S2I,S1I,DTI 设置成输入口
//P2REN |= S2I+DTI+S1I; //上拉使能
//P2OUT |= (S2I+DTI+S1I); //上拉动作
P2IES |= (S2I+S1I+DTI); // S2I+S1I+DTI 下降沿触发
P2IE = S2I+S1I+DTI; // 使能 S2I+S1I+DTI 输入中断
P2IFG = 0; // 清除 P2 口中断标志
P1SEL0 |= RX | TX; // P1.5和P1.4分别设置成 RX 和 TX
P1DIR |=(PS1+PS2+PDT); //S2I,S1I,DTI power control outputs
P1OUT |= (PS1+PS2+PDT);
P1DIR |=DERE; //S2I,S1I,DTI 设置成输出口
P1OUT &=~DERE; //控制485IC读写功能,低位MCU接收,高为MCU发送
P1OUT |= BAT_GND;
P1OUT |= AD_BAT; //p1.0 口电压检测口
SYSCFG2 |= ADCPCTL0; // P1.0 设置成 ADC A0检测口
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
}
我给你说的只是个想法。我觉得你现在已经用了LPM4模式,那么LPM3模式等等几个模式是否可用呢。这个需要你根绝实际情况看下,这样情况下,其他模式是否可用,以此来降低功耗。这个您再看看呢
一周热门 更多>