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.

RTOS/CC2640: RTOS/CC2640 BLE 2.2.2.25 Notification of ENTERING_SHUTDOWN when device entering standby mode?

Part Number: CC2640

Tool/software: TI-RTOS

Gang,

With BLE 2.02.02.25 on a CC2640, using a derivative of the simpleCentral, we have used the Power_shutdown() command for a while, and it works fine.

Today we decided to fine tune the process.

We now register for notification when it goes into shutdown so we can toggle one GPIO port once as follows:

Power_registerNotify(&PowerNotifyObject, Power_ENTERING_SHUTDOWN, (Power_NotifyFxn)NotifyShutdownInProgress, NULL);

We expect to be notified if, and only if, the device is going into shutdown --- since we did not ask for standby notification, or any other kind of notification.

We immediately experienced strange behavior: 18 notifications that appear to be coincident with the device going into STANDBY (the result of a fewf Task_sleep() calls of varying lengths). We commented out the Power_shutdown() command entirely.

Nowhere in the program do we now call that function.  And we do NOT go into shutdown.  Just standby. We are still registering to be notified when the device goes into SHUTDOWN (not standby, not idle).

We are still getting 18 notifications in a row, and the callback function shows the parameters we are receiving are  4, 0, 0 each and every time.  That appears to be Power_ENTERING_SHUTDOWN. But as I said, it sure appears as if it is notifying us it is going into Standby mode, which of course it is.

Looking forward to some pointers here...

  • Hi,
    Have you been able to measure the power consumption to verify which power mode is used?
  • Hi Happy,

    You are subscribing to a define that isn't the notification ID, but the internal state, which happens to overlap with PowerCC26XX_AWAKE_STANDBY. You should be subscribe to PowerCC26XX_ENTERING_SHUTDOWN instead. Remember to #include <ti/drivers/power/PowerCC26XX.h> to get this define.

    Best regards,
    Aslak
  • Joakim,

    We do measure the current, and track when we go into standby (for example, in a Task_sleep(), versus full shutdown. In this case we are going into full shutdown.

    Richard
  • Thanks Aslak, good eye. That did the trick. Now we are getting one notification as it goes into shutdown. Thanks again!
  • Hmmmm…. Need to revisit this topic.

    We are now able to register for notification on shutdown using
    Power_NotifyObj PowerNotifyObject;
    Power_registerNotify(&PowerNotifyObject, PowerCC26XX_ENTERING_SHUTDOWN, (Power_NotifyFxn)NotifyShutdownInProgress, NULL);

    When we request shutdown with
    DEBUG_ShutdownResponse = Power_shutdown(NULL, 10000);
    We get notified shortly thereafter, and the device DOES go into shutdown.

    A minute later it resets from shutdown, comes up through main() to the main task, and once again we tell the OS to notify us.
    (The code in the application task is, of course, unchanged. Same code, coming up out of reset.)
    Power_registerNotify(&PowerNotifyObject, PowerCC26XX_ENTERING_SHUTDOWN, (Power_NotifyFxn)NotifyShutdownInProgress, NULL);

    This time, however, the outcome is different.
    When we request Power_shutdown (same as before) it fails.
    Not sure what error code it returns, since the debugger is not connected, but it is definitely not
    Power_ECHANGE_NOT_ALLOWED or Power_EBUSY or Power_EFAIL.

    So, if I request Power_registerNotify() it succeeds once, then fails all subsequent returns from a reset condition.
    If I comment out that one line registering our interest, it successfully goes back into shutdown mode as desired.

    So it looks as if registering for notification is the cause of the problem.... meaning I am not doing something that needs to be done to clean it out or prepare it anew.

    Is it possible I need to clean out the PowerNotifyObject this second time around before I pass it to the Power_registerNotify() function?
    Do I need to UNREGISTER my interest before I go into shutdown each time?
  • I found another define, Power_EINVALIDPOINTER and plugged that in.... the program is now indicating that is the error code being returned.

  • Partial solution.... tracking the problem further as indicated in the parallel posts.
  • Hi Happy,

    I am not able to reproduce your issue. Modified the pinShutdown driver example:

    // Added this function / notify object
    Power_NotifyObj PowerNotifyObject;
    
    int NotifyShutdownInProgress(unsigned int eventType, uintptr_t eventArg,
                                   uintptr_t clientArg)
    {
        PIN_setOutputValue(hPins, Board_LED0, 0);
        return Power_NOTIFYDONE;
    }
    
    // Comment out the original LED0 turn-off that signifies going to shutdown
    static void taskFxn(UArg a0, UArg a1)
    {
    // ...
        /* Turn off LED0 */
    //    PIN_setOutputValue(hPins, Board_LED0, 0);
    // ...
    }
    
    // Subscribe in main()
    int main(void)
    {
    // ...
      Power_registerNotify(&PowerNotifyObject, PowerCC26XX_ENTERING_SHUTDOWN, (Power_NotifyFxn)NotifyShutdownInProgress, NULL);
      BIOS_start();
      return 0;
    }

    Best regards,
    Aslak

  • Aslak,

    I see a new value in the mix:  You are returning Power_NOTIFYDONE

    At the same time, I see you have defined your notification routine as an int function --- I will try both of these out.

    Where did you find the API or explanation describing what that callback routine needs to return?  I had looked and found nothing in the Power Management pdf document.

    Richard

  • Aslak,

    The addition of returning Power_NOTIFYDONE fixed the problem.

    Failing to do that, going into shutdown, then registering for notification again causes failure of some sort that relates to the initialization or lack thereof of the PowerNotifyObject. This suggests the OS preserves this notification list from shutdown to shutdown... which I doubt. Must be something else at work.

    Btw, we are very interested in finding a full API list with details on what parameters are expected or required, especially on this sort of callback.
  • Happy,

    I didn't really look at the documentation as much as the definition/signature of the Power_NotifyFxn function typedef, and then found power notify responses defined a bit higher up in the same file (Power.h). Finally searched for occurrences of Power_NOTIFYDONE in the drivers to verify my assumption.

    Now that I tried to find documentation I must admit failure. I'm not sure that it is described very well if at all; I think it has been considered mostly as an API for drivers and not so much for end users.

    Best regards,
    Aslak