|
测试开机运行10秒后,进入LPM4深度睡眠完全掉电。由P1.3外部中断唤醒后进入正常工作,10秒后再度进入掉电,如此循环,验证正确。
extern unsigned char count;
/* ======== main ======== */
int main(void)
{
Grace_init(); // Activate Grace-generated configuration
for(;;)
{
if(count >= 10)
{
__bis_SR_register(LPM4_bits + GIE); // Enter LPM0 w/ interrupt
}
}
return (0);
}
#pragma vector=PORT1_VECTOR
__interrupt void PORT1_ISR_HOOK(void)
{
count = 0; //进入中断后把时间计数器清0
if((P1IFG&BIT3) ==BIT3)
{
P1IFG &= ~BIT3; //清标志位
P1OUT ^= BIT6; //P1.6 = toggle
}
LPM4_EXIT; //退出中断后退出低功耗模式。若退出中断后要保留低功耗模式,将本句屏蔽
}
/*
* ======== Timer0_A3 Interrupt Service Routine ========
*/
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR_HOOK(void)
{
P1OUT ^= BIT0; // P1.6 = toggle
count++;
}
|
|