进入休眠或掉电模式,按键(P0.3脚)触发唤不醒: 程序如下: int main (void) { Init_EINT1();// Init_Beep(); while(1) { PCON |= 0X02; //Power_down(keynum); IO0CLR = BEEP; //蜂鸣器叫 DelayNS(10); //OSTimeDly(50); IO0SET = BEEP; DelayNS(10); //OSTimeDly(50); } } void Init_Beep(void) { PINSEL0 &= ~(0x03 << 26) ; //选择GPIO状态 IO0DIR = BEEP; //方向输出 IO0SET = BEEP; //禁止鸣叫 } void Init_EINT1(void) { PINSEL0 |= EINT1 ;//(EINT0 | EINT1 | EINT2 | EINT3); EXTMODE &= ~0X02; //电平触发 EXTPOLAR&= ~0X02; //低电平有效 EXTWAKE |= 0X02; //使能唤醒 //VICIntEnable = 1<<15; //不需要使能中断,仅仅从掉电模式唤醒,但不产生中断 }
|