CC2541做BLE从机,进入PM3后,P1及P2中断唤醒后有执行sleep后的操作,但马上死机
#pragma vector = P1INT_VECTOR
__interrupt void port1_isr(void)
{
// Note that the order in which the following flags are cleared is important.
// Clear Port 1 Interrupt Flags.
P1IFG = 0x00;
// Clear CPU Interrupt Flag for P1 (IRCON.P1IF = 0).
P1IF = 0;
PCON = 0;
}
#pragma vector = P2INT_VECTOR
__interrupt void port2_isr(void)
{
// Note that the order in which the following flags are cleared is important.
// Clear Port 2 Interrupt Flags.
P2IFG = 0x00;
// Clear CPU Interrupt Flag for P2 (IRCON.P2IF = 0).
P2IF = 0;
PCON = 0;
}
...
50ms周期处理中
// 保护中断设置
IEN0BAK = IEN0;
IEN1BAK = IEN1;
IEN2BAK = IEN2;
EA = 0;
// P1及P2中断设置
P2IEN = 0xff;
P1IEN = 0xff;
HAL_BG = BACK_LIGHT_OFF; // LED 关
IEN0 = 0;
IEN1 = 0;
IEN2 = 0x12; // P1、P2中断使能
EA = 1;
/***************************************************************************
*/
// Set power mode, PM3.
SLEEPCMD = (SLEEPCMD & ~SLEEPCMD_MODE) | SLEEPCMD_MODE_PM3;
// Force the device to enter the power mode set by SLEEPCMD.MODE.
EnterSleepModeProcessInterruptsOnWakeup();
EA = 0;
CLKCONCMD &= ~0x40; // 设置系统时钟源为 32MHZ晶振
while(CLKCONSTA & 0x40); // 等待晶振稳定
// 关P2、P1中断
P2IEN = 0;
P1IEN = 0;
HAL_BG = BACK_LIGHT_ON; // LED 开
// 恢复中断设置
IEN2 = IEN2BAK;
IEN1 = IEN1BAK;
IEN0 = IEN0BAK;
进入PM3后,LED灭,这时按键(P1、P2)后,LED亮,但程序马上死机,按键操作无反应,查32MHz晶振有信号
不清除其它中断则进入SLEEP后马上又醒了,这个情况下是不会死机,按键操作正常。是否BLE中断造成的呢?
PM1方式唤醒后操作正常,似乎与Voltage Regulator的关闭有关,TI的工程师能解释下吗?