This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Can't wake up from PM2 using Sleep Timer

Other Parts Discussed in Thread: Z-STACK, CC2530

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

  • If you intend to make CC2530 goes to sleep in Z-Stack, I would suggest you using API halSleep.
  • hi Yikai, thank you for your quick answer as usual ;)

    if i understood correctly the manual, the halSleep function runs constantly in the background, and puts automatically the device to sleep until the next timer expires. But my ED has the antenna always on (-DRFD_RCVC_ALWAYS_ON=TRUE in the Config.cfg file) so the halSleep should not work...right?
  • No, I don't see RFD_RCVC_ALWAYS_ON is related to halSleep.
  • i read it on the section 4 of the Power Management application note (SWRA248). But it makes sense to me, since if the antenna is always on, this means that any device can send you a message at any moment, so you can't go to sleep automatically.

    Anyway, if having the antenna always on doesn't matter, than what should i do? I mean, i think i'm setting the Sleep Timer properly, but probably i'm doing something wrong in handling the ISR or something in the waking-up part
  • If you define RFD_RCVC_ALWAYS_ON=TRUE and POWER_SAVING in your application, does it work for you?
  • No, if i dont'use the cose above the device doesn't go to sleep ''automatically'' thanks to the halSleep running in the background
  • Can you set a breakpoint in halSleep to check if it is called when you define RFD_RCVC_ALWAYS_ON=TRUE and POWER_SAVING in your application?
  • i tried to put the breakpoint and debug and something weird happened: i have a red led blinking when the device starts, and the red light got stucked on, even if the device was actually sleeping, or at least i think it was (i could see it because pressing a button on the board should cause another led to blink, but nothing was happening like when it's sleeping); then i commented the PCON = BV(0) instruction and tried again: this time nothing weird happened but i never breaked to the halSleep function, and of course the device didn't go to sleep. Then i set RFD_RCVC_ALWAYS_ON=TRUE and -DPOLL_RATE=5000, and tried to debug again: even this time i never breaked at the halSleep function, so i supposed it is not running at all! Of course i have the POWER_SAVING option in the preprocessor defined symbols, but it looks like i am missing something else...

    anyway, breaking news: i left the sniffer on during the last hours and i noticed that the device was actually waking up periodically, with a 508 seconds period! So it looks like the Sleep Timer is working after all, but i don't understand why the period is 508s...the timer registers were 00-00-30, so shouldn't it be 48*320us=15,36ms?