hi everyone,
i'm running an application in which i have an ED with the antenna always on, and i need to put it to sleep and wake it up with an external interrupt or periodically with the Sleep Timer. With the external interrupt everything works fine, but i can't wake it up with the sleep timer. This is my code to put it to sleep (i call this event 5 seconds after the power up)
if ( events & SLEEP_EVT )
{
//set the timer
ST2 = 0x00;
ST1 = 0x75;
while (STLOAD == 0)
{
asm("nop");
}
ST0 = 0x30;
// Enable interrupts
STIF = 0; //clear flag
STIE = 1; //enable int
IEN0 |= BV(5); //HAL_SLEEP_TIMER_ENABLE_INT
HAL_ENABLE_INTERRUPTS();
//go to PM2
MAC_PwrOffReq(MAC_PWR_SLEEP_DEEP);
SLEEPCMD &= ~PMODE; /* clear mode bits */
SLEEPCMD |= 0x02; //HAL_SLEEP_TIMER
PCON = BV(0);
asm("nop");
// return unprocessed events
return (events ^ SLEEP_EVT);
}
i've set the timer to 00-75-30 since it should be about 30 seconds, but even using a smaller or bigger value doesn't change the behaviour. I've tried to comment the MAC_PwrOffReq(MAC_PWR_SLEEP_DEEP) but nothing changes.
from my understanding when the ED wakes up, it should go to the ISR in hal_sleep.c, and i added SystemReset() to it, since i want the device to reset when it wakes up. Of course the device never resets...i've also tried to add the SystemReset() after the asm("nop") in the SLEEP_EVT but no results
i'm using 2007 ZigBee Pro Stack, IAR 8051 8.10 and CC2531, and in this tries i'm not using any coordinator, just the end device
what am i doing wrong?
Regards
Claudio