您好!
我有以下代码、在一定程度上发挥作用:
void main(void) {
WDTCTL = WDT_ARST_1000; // start watchdog timer, 1 second
if (LPM45CTL & LPM45IFG) {
// If system wakes up from LPM4.5
// Clear GPIO state lock so PINs can be configured
LPM45CTL &= ~LOCKLPM45;
}
// Setup TA0.0 to wake up system every 100 mini-second
TA0CCTL0 = CCIE; // CCR0 Interrupt Enabled
TA0CCR0 = 1638; // 50ms ticker
TA0CTL = TASSEL_1 | MC_1 | TACLR; // ACLK, UP, devided by 8
while(1) {
// Do something
// Then kick the dog
WDTCTL = WDT_ARST_1000;
// If explicitly instructed by external MCU to go into LPM3
// Otherwise LPM4/4.5
if(P2IN & BIT1) {
__bis_SR_register(LPM3_bits | GIE); // Enter LPM3
} else {
// LMP4.5 code commented out
//WDTCTL = WDTPW | WDTHOLD; // Stop WDT to be safe. May actually unnecessary
//LPM45CTL &= ~LOCKLPM45;
//LPM45CTL |= PMMREGOFF;
//__bis_SR_register(LPM4_bits);
__bis_SR_register(LPM4_bits | GIE);
}
}
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=PORT2_VECTOR
__interrupt void PORT2_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(PORT2_VECTOR))) PORT2_ISR (void)
#else
#error Compiler not supported!
#endif
{
if(P2IFG&BIT1) {
P2IFG &= ~BIT1;
__low_power_mode_off_on_exit ();
}
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TA0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) TA0_ISR (void)
#else
#error Compiler not supported!
#endif
{
// Just wake up to kick the dog if not anything else
__low_power_mode_off_on_exit ();
}
问题是功耗。 当系统编程进入 LMP4.5时、功耗符合预期、约为0.1mA。 但是、当系统被编程进入 LPM3或 LPM4时、两种 LP 模式的功耗几乎相同、保持在0.4mA 附近、而预计会出现0.18mA 差异、因为 LPM3和 LPM4的基线功耗不同(LPM3为250uA、LPM4为70uA)。
我在这里犯了什么错?
谢谢。
ZL