CC2640R2F: Not able to wake up from StandBy Deepsleep State using gpio

Part Number: CC2640R2F

Hello,
I am working on TI CC2640R2F Launch Pad.
I am having issue in waking up from standby deep sleep state. 
I am trying to wake up using a Button interrupt on BTN-1 or DIO13.
I am using same button for waking up from shutdown mode and it works for shutdown mode.
Here's my code snippet for shutdown mode and stanby mode.

void *mainThread(void *arg0)
{
   Semaphore_Params standbySemParams;
   Semaphore_Params_init(&standbySemParams);
   standbySem = Semaphore_create(0, &standbySemParams, NULL);

    /* Call driver init functions */
    GPIO_init();
    I2C_init();
    SPI_init();
    UART_init();

    GPIO_setConfig(Board_GPIO_LED1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

   PIN_Config wakePin[] ={ Board_PIN_BUTTON0 | PIN_INPUT_EN | PIN_PULLUP | PINCC26XX_WAKEUP_NEGEDGE, PIN_TERMINATE};

     for (;;) {
        switch (appState) {
          case APP_STATE_ACTIVE:
          {
                if (Semaphore_pend(standbySem, BIOS_NO_WAIT)) {
                appState = APP_STATE_STANDBY;
                }
          break;
          }
          case APP_STATE_SHUTDOWN:  //when called Power_shutdown controller wakesup with same wakepin from shutdown and restarts main routine
          {
               PINCC26XX_setWakeup(wakePin);     Thumbsup
               Power_shutdown(0, 0);         Thumbsup
           break;
           }
          case APP_STATE_STANDBY:
          {           
           GPIO_toggle(Board_GPIO_LED1);   /* about to sleep */
           Power_sleep(PowerCC26XX_STANDBY);        Thumbsdown    //problem is here when it enters Power_sleep it goes into deepsleep mode and never responds to button press interrupt
 
           GPIO_toggle(Board_GPIO_LED1);   /* wakeup from sleep */  Thumbsdown
           break;
           }
        }
     }
}

Power_sleep gets stuck inside PRCMDeepSleep
 /* 13. Invoke deep sleep to go to STANDBY */
 PRCMDeepSleep();

What could be possible solution to wakeup from deepsleep standby using wakeup pin and LED1 toggle activates which stands right after Power_sleep() call?
Thanks
  • Hi Yash, thanks for the detailed description of your issue. There are actually two separate problems at play here, and addressing both will get you up and running.

    Problem 1: Do not call Power_sleep() manually for standby. On the CC2640R2F with TI-RTOS, you should never call
    Power_sleep(PowerCC26XX_STANDBY)
    directly. The RTOS power manager handles this automatically when there are no active tasks or events, the device will naturally transition to standby. Calling it manually can actually prevent the device from entering the correct low-power state or cause it to hang at
    PRCMDeepSleep() 

    if a
    PowerCC26XX_SB_DISALLOW
    constraint is set by an active peripheral. In your code, you have:
    GPIO_init(), I2C_init(), SPI_init(), and UART_init()
    all called at startup, any one of these with active operations can set that constraint and block standby entry. Remove the explicit
    Power_sleep()
    call, and let TI-RTOS manage standby automatically by having your task block on a semaphore (which you already have with standbySem).
    Problem 2: Your button ISR must post a semaphore or event to wake the task The second issue is that simply configuring a GPIO interrupt is not enough to wake your application task from standby. When the button fires, the ISR must explicitly signal a TI-RTOS kernel object (semaphore or event) to unblock the waiting task. You need to register a PIN interrupt callback on
    Board_PIN_BUTTON0
    using:
    PIN_open and PIN_registerIntCb
    , and inside that callback, call
    Semaphore_post(standbySem).
    Your main task loop is already pending on
    standbySem
    so, when the button is pressed, the ISR posts the semaphore, which unblocks the task and causes the RTOS to bring the device out of standby. The
    PINCC26XX_WAKEUP_NEGEDGE
    flag in your
    wakePin
    config is correct for waking from shutdown but for standby you need the registered ISR + semaphore post mechanism. I would also recommend reviewing the
    pinStandby
    example in the SimpleLink CC2640R2 SDK, as it demonstrates exactly this pattern.
    Please let me know if this solves your problem.