Dear all,
I have a problem with PM2 and sleep timer. And my project is based on BasicRF sample for cc2530.
My application needs sleep timer to call MCU back to active from PM2. So i test sleep timer first. In halBoardInit() function, i set up sleep timer as follows:
//sleep timer
halStartSleepTimer();
halSetSleepTimer(4);
In sleep timer ISR, i set a flag named sleepTimerFlag as follows:
#pragma vector= ST_VECTOR
__interrupt void sleepTimer_IRQ(void)
{
STIF=0;
SLEEPCMD &= 0xfc;
sleepTimerFlag = 1;
}
And in while loop located in Main function, i check the sleepTimerFlag flag. if this flag is set, then i toggle a LED, clear the flag to 0, and set up all the sleep timer paras.Finally, i make cc2530 into PM2 state. It is listed as follows:
while(1)
{
if(basicRfPacketIsReady())
{
.....................................
}
if(sleepTimerFlag == 1)
{
sleepTimerFlag = 0;
halLedToggle(2);
halStartSleepTimer();
halSetSleepTimer(3);
halSetPowerMode(2); //Problem here
}
}
The code snap listed above is the program schedule i want to achieve.
The problem is, if i add the halSetPowerMode(2) in while loop, i can't see my LED toggle after some seconds, which means that cc2530 can't get into the sleep timer ISR.
If i remove the halSetPowerMode(2) in while loop, i can see my LED toggle all the time.
So, is there any relationship between halSetPowerMode(2) and Sleep timer ?
Thanks a lot!