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.

How to wake up the CC2650 and keep running the FW

Other Parts Discussed in Thread: CC2650, CC2640

Hi,

I do those fun like below in static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)

PowerCtrlStateSet(PWRCTRL_STANDBY);

or

PowerCtrlStateSet(PWRCTRL_SHUTDOWN);

after one of these Power setting the CC2650 seems into standby or shutdown mode.

I also do these setting for GPIO

void Board_initKeys(keysPressedCB_t appKeyCB)
{
// Initialize KEY pins. Enable int after callback registered
hKeyPins = PIN_open(&keyPins, keyPinsCfg);
PIN_registerIntCb(hKeyPins, Board_keyCallback);

PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_SELECT | PIN_IRQ_NEGEDGE);
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_UP | PIN_IRQ_NEGEDGE);
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_DOWN | PIN_IRQ_NEGEDGE);
PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_LEFT | PIN_IRQ_NEGEDGE);
//PIN_setConfig(hKeyPins, PIN_BM_IRQ, Board_KEY_RIGHT | PIN_IRQ_NEGEDGE);

//#ifdef POWER_SAVING
//Enable wakeup
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_SELECT | PINCC26XX_WAKEUP_NEGEDGE);
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_UP | PINCC26XX_WAKEUP_NEGEDGE);
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_DOWN | PINCC26XX_WAKEUP_NEGEDGE);
PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_LEFT | PINCC26XX_WAKEUP_NEGEDGE);
//PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_RIGHT | PINCC26XX_WAKEUP_NEGEDGE);
//#endif

// Setup keycallback for keys
Util_constructClock(&keyChangeClock, Board_keyChangeHandler, KEY_DEBOUNCE_TIMEOUT, 0, false, 0);

// Set the application callback
appKeyChangeHandler = appKeyCB;
}

and what should I do after press the buttons wake up the MCU and keep running the FW.

Thanks 

  • Vincent,

    • Do not use the PowerCtrl API. This is low-level drivers that should not be called in a TI RTOS context as TI RTOS has its own power manager that will go to the lowest power mode available when no tasks are running (blocked pending on Semaphore_pend, Event_pend, Task_sleep etc)
    • You can prevent it from going to Standby when needed by using Power_setConstraint/Power_releaseConstraint with Power_SB_DISALLOW as argument.

    The PINCC26XX_WAKEUP_* is only needed for Shutdown mode. It seems the Board_initKeys example you are looking at does not implement this correctly.

    A proper way to do this would be:

    PIN_State  keyPins;
    PIN_Handle hKeyPins;
    
    void pinCallback(PIN_Handle hPin, PIN_Id pinId) {
     //Do stuff with pins
    }
    
    void someFunction() {
      PIN_Config keyPinsCfg[] =
      {
          Board_KEY_SELECT    | PIN_GPIO_OUTPUT_DIS  | PIN_INPUT_EN  |  PIN_PULLUP | PIN_IRQ_NEGEDGE,
          Board_KEY_UP        | PIN_GPIO_OUTPUT_DIS  | PIN_INPUT_EN  |  PIN_PULLUP | PIN_IRQ_NEGEDGE,
          Board_KEY_DOWN      | PIN_GPIO_OUTPUT_DIS  | PIN_INPUT_EN  |  PIN_PULLUP | PIN_IRQ_NEGEDGE,
          Board_KEY_LEFT      | PIN_GPIO_OUTPUT_DIS  | PIN_INPUT_EN  |  PIN_PULLUP | PIN_IRQ_NEGEDGE,
          Board_KEY_RIGHT     | PIN_GPIO_OUTPUT_DIS  | PIN_INPUT_EN  |  PIN_PULLUP | PIN_IRQ_NEGEDGE,
          PIN_TERMINATE
      };
    
      hKeyPins = PIN_open(&keyPins, keyPinsCfg);
      PIN_registerIntCb(hKeyPins, pinCallback);
    }

    This is really all you need and the system will go into standby by itself and wake up when pressing a button and call pinCallback from the pin driver HW interrupt.

    .:svend

  • Hi,

    In addition, there is a working example of waking up the MCU and keeping it awake, in the HostTest Application. Please refer to the NPI code, specifically, npi_tl.c & npi_tl_uart.c. This requires use of the MRDY & SRDY pins.

    Best wishes
  • Hi svend,

    First:
    Thank you for GPIO wake up the MCU example and
    If I want the RTOS on CC2640~50 has the Idle, standby, and shutdown mode.
    I should use these
    Power_releaseConstraint(Power_SB_DISALLOW);
    Power_releaseConstraint(Power_IDLE_PD_DISALLOW);
    Enable these mode.

    in the other side I can use these
    Power_setConstraint(Power_SB_DISALLOW);
    Power_setConstraint(Power_IDLE_PD_DISALLOW);
    Disable these mode.

    Does it right?

    Second:
    After these Power_setConstraint/Power_releaseConstraint setting.
    When the RTOS on CC26xx occur Idle, standby, and shutdown mode.
    Because I try Task_sleep(500000) but the MCU currect still 0.64mA.
    Could you be more specific.

    Thanks
  • Hi,

    As Svend had mentioned TI-RTOS chooses the best power mode. We can instruct TI-RTOS to not allow StandBy by calling Power_setConstraint(Power_SB_DISALLOW); This way TI-RTOS will not allow the CC26xx to go to Stand By although there is nothing else to do.

    When required you can release this constraint by calling Power_releaseConstraint(Power_SB_DISALLOW);. This means whenever CC26xx is idle(task_sleep, sem_pend, event_pend), the TI-RTOS might choose to go stand By mode.

    If you don't make any of these calls in your application, TI-RTOS power manager chooses the best possible low power mode automatically. You dont need to set the constraints and release them if you don't care whether the MCU sleeps in between some driver access(like in NPI_tl.c and NPI_tl_uart.c)

    As for your question on why the current is 0.64mA even after calling Task_sleep(500000), is that TI-RTOS might have instructed the MCU to got Stand By mode when the MCU is IDle, but since you might be in a BLE connection, depending upon the connection parameters used, the MCU will wake up to send & recieve BLE packets(RF Tx and RX) and after that go back to sleep.

    So even if your had given sleep for 500,000 ticks, if the connection interval was say 500 ticks. then your system would have woken up 1000 times during this interval for BLE transmission.

    So your effective power consumption might be (450(idle ticks)*1uA + 50(Active ticks for a BLE transmission)*6000uA)/500 ~= 600uA

    Regards,

    Arun

  • Hello Arun ,

    Can you tell me how can Rtos can put the CC2650 module into shutdown mode.
    If i am able to put it how can I wake it up .

    Regards,
    Rahul
  • Hi,
    Thank you for these reply.
    I stop each Task and I got 0.02mA.

    Thanks again.
  • The TI-RTOS Power manager decides to put the system into the lowest possible power mode whenever possible. So unless you restrict the system(by putting constraints or doing some heavy processing) the RTOS will put the system to Standby mode(In shutdown mode even RAM is not retained). You can wake up from Standby by GPIO interrupt(pin level change) or RTC events. To wake up from Shutdown you can configure the GPIO to wake up on pin level change(RTC inteerupts wont wake up the CC26xx from Shut down) as shown below

    PIN_setConfig(hKeyPins, PINCC26XX_BM_WAKEUP, Board_KEY_SELECT | PINCC26XX_WAKEUP_NEGEDGE);

    Regards,
    Arun
  • vincent kuo said:
    Hi,
    Thank you for these reply.
    I stop each Task and I got 0.02mA.

    Thanks again.

    Vincent,

    I would strongly recommend to read through the BLE software developers user guide for a better understanding of power management in a RTOS context.

    BR,
    Svend

  • vincent kuo said:
    Hi svend,

    First:
    Thank you for GPIO wake up the MCU example and
    If I want the RTOS on CC2640~50 has the Idle, standby, and shutdown mode.
    I should use these
    Power_releaseConstraint(Power_SB_DISALLOW);
    Power_releaseConstraint(Power_IDLE_PD_DISALLOW);
    Enable these mode.

    in the other side I can use these
    Power_setConstraint(Power_SB_DISALLOW);
    Power_setConstraint(Power_IDLE_PD_DISALLOW);
    Disable these mode.

    Does it right?

    Second:
    After these Power_setConstraint/Power_releaseConstraint setting.
    When the RTOS on CC26xx occur Idle, standby, and shutdown mode.
    Because I try Task_sleep(500000) but the MCU currect still 0.64mA.
    Could you be more specific.

    Thanks

    Vincent,
    Please note that the constraints are implemented as a counter so you must always have the same number of set as your have clear. By default both IDLE and STANDBY modes are enabled.
    Also, to have control of sleep times you should compensate for the OS tick period. To sleep e.g. 10 ms you would need to run Task_sleep(10 * 1000 / Clock_tickPeriod);.
    BR,
    Svend
  • Hello Arun,

    Thank for Reply.

    In Regards to Putting the CC2650 module in Standby and shutdown mode by TI - RTOS , as per my understanding we have to configure the TI-RTOS variable in appBLE.cfg file and we have to assign a particular power policy as I have seen in this file .

    /* Idle CPU when threads blocked waiting for an interrupt */
    Power.idle = true;
    Power.policyFunc = Power.standbyPolicy;
    Power.calibrateRCOSC = false;

    Tell me if I am wrong .

    And when Idle Loop is executing this power policy will be follow or I can say RTOS in Idle mode will call Power_standbyPolicy function which is defined in Power_standbyPolicy.c file.

    But when I observe this function I have seen there is no option provide for RTOS to put the module in shutdown mode . Even if we disallow the Standby or Powerdown mode . 

    So, I want to ask is there any other policy which will put the CC2650 in shutdown mode or I can configure it manually.

    Regards,

    Rahul Sharma

  • Hello Arun,

    Also in regards to power consumption during stand by mode,I have created setup in accordance to the "Measuring Bluetooth® Smart Power Consumption " (Application Report :Dated February 15) and observing the current consumption to be 9 Micro amp .
    I have created no tasks for the RTOS to handle and hence the system enters standby mode and still the current consumption is 9 micro amp.

    However ,as per the latest Technical Reference Manual the current consumption in stand By mode is around 1 micro amp(excluding RTOS overhead).

    Am I observing additional 8 micro amps as a result of RTOS running ??

    Regards,
    Rahul Sharma
  • Rahul,

    The guide you point to is a BLE project showing how to measure the average current for a given connection interval.
    This includes the cost of waking up the device periodically and maintaining a connection.

    If you want to purely test standby current the only thing you should have in main() is BIOS_start();

    There is also a note at the end of chapter 4.3 mentioning an opamp which is mounted on older SmartRF06 boards which adds approx 10uA.
    This must be removed on these boards (can be skratched of with a finger nail).

    .:svend
  • Hi Rahul,

    You are correct. The power policy is defined in appBLE.cfg as you have mentioned. Your understanding on how TI-RTOS puts the MCU in StandBy mode is correct. As for Shutdown mode, it is not currently implemented by the power manager(policy). But it will be available soon with next SDK release.

    Regards,
    Arun
  • Shutdown mode is supported by a direct API (Power_shutdown).

    Remember to set a wake-up pin from shutdown using the PIN driver before entering shutdown.

    Regards

    Svend

  • Thanks for the reply.

    Is this approach would not effect RTOS because as before mentioned post I have seen that we should not directly use the Power api .
    And wen the new SDK would release .
    Regards,
    Rahul Sharma
  • Hi Rahul,

    The Power_ API in TI RTOS is supported for customers to use which means you can use shutdown if you would like to.
    What is not possible to use is the low-level driverLib calls inside driverLib (part of CC26XXWARE). These are only to be used in non-RTOS related projects.

    .:svend
  • Thanks for the reply.

    If I use Power-shutdown api with RTOs to put the cc26xx module in shutdown mode and try to wake it up by Pin edge.

    Then can i receive it as interrupt in any defined callback function and after wake up from where it would start its execution.

    Regards,

    Rahul Sharma 

  • Rahul,

    You can use the driverLib function SysCtrlResetSourceGet which returns RSTSRC_WAKEUP_FROM_SHUTDOWN after shutdown to call your needed code.
    Since there are no retention in Shutdown except for IOs latched to their values before shutdown the full device needs to restored.
    The device starts executing code as you would from a power on.

    Regards,
    Svend
  • Hi Svendbt,

    My problem is very similar to the Rahul. I'm using the SensorTag and would put it in shutdown so the main function. Once pressed the button it would wake up and perform normally.

    See the code.


    Void main()
    {
    SensorTagIwatch_Init();

    PIN_init(BoardGpioInitTable);
    // Enable iCache prefetching
    VIMSConfigure(VIMS_BASE, TRUE, TRUE);
    ...
    }


    void SensorTagIwatch_Init( void )
    {
    if( SysCtrlResetSourceGet() != RSTSRC_WAKEUP_FROM_SHUTDOWN ) //
    {
    PIN_Config shutdownIO[] = {
    Board_KEY_LEFT | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP | PINCC26XX_WAKEUP_NEGEDGE,
    PIN_TERMINATE };
    PINCC26XX_setWakeup(shutdownIO);
    Power_shutdown(NULL);
    }
    }

    the problem is that I can not make it back to run the code. it goes into shutdown, but it does not wake up more. When I see the current draw when I press the button to wake the sensorTag, it is approximately a 4mA.
  • Hugo,

    You are calling a RTOS API before you have started TI RTOS. The only TI RTOS API that should be called before BIOS_start() is setting up tasks and running PIN_init.


    Regards,
    Svend

  • hello Arun menon,
    I have a problem,when i finish configure the GPIO to wake up on pin level change Like you said above,and the mcu Work in Shutdown,If I press the button, where the program continues to run?I tried, it seemed to run not normal.