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.

CC2540 Sleep timer

Other Parts Discussed in Thread: CC2540

Hello,

I'm trying to wake the CC2540 from PM2 using the sleep timer.

However, it seems that the sleep timer compare will not trigger. So now as a first step I'm just trying to get the sleep timer to trigger interrupts without sleeping first.

Should this be enough to create a sleep timer event in IAR?

#pragma vector=ST_VECTOR
__interrupt void sleepTimer(void)
{
}

main()
{
  // Init main clock first
   ...
  while(!(STLOAD & 0x01));
  ST2 = 0x00;
  ST1 = 0x00;
  ST0 = 0x10;
  IEN0 = 0xA0;
 while(1);
}

  • That looks like enough to me. I would put an asm("NOP"); in the sleepTimer() ISR to be able to set a break point. And since there is IAR init stuff that runs before you get control in main(), the ST may have already ticked more than 11 counts, so you may have to wait the full ~8.5 minutes to get your ISR. So you should first read the ST values, add to them the delay you desire, and then set them. So above all, why not use the sample code from the hal_sleep.c module in the BLE stack to get a head start?

  • Thank you for the response, I now noticed that I indeed have an interrupt after the full wrap around time. I was surprised that there was no way to reset the timer, but adding the compare value will work too. I was indeed checking the hal code for reference but I guess I missed this part.