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 wakeup button

Other Parts Discussed in Thread: CC2540, CC2541

Dear all, I am going to design a wakeup button. It is used to wakeup the system from PM3 mode.

The OSAL and HAL document do not mention much about the interrupt function.

Could you please tell me more about where I can find out more about writing the above interrupt handling sub-routine?

Thank you!

  • Hello,

    You may want to look at the _hal_key.c code for example on how it is used by simpleBLEPeripheral (registerForKeys funtion) project example which has mix of interrupt and polling.

    Br,

    -Greg 

  • Hi Greg,

    I have had a look at the hal key source code, but i am still not sure how to move forward. could you please comment on the following:

    To design such a button, one have to:

    SWITCH OFF
    1) process button event (I am okay at this)
    2) change the power mode to PM3.
    ...
    SWITCH ON
    3) catch the button event
    4) switch it back to Active power mode

     

    for step 1, the Interrupt in simpleBLEPeripheral is done by catching the OSAL event;

    What i am not sure about is the following steps

    step2: It seems none of the HAL and OSAL functions could be used for changing the Power Mode, doesn't it? so I must access the SFR resigters to change the power mode.

    step3: Given the system is in PM3 at the moment, once the system is interrupted by a switch (SW1 at port1), would it behave the same way as in step1? all i need to do is to catch the event using the simpleBLEPeripheral_ProcessOSALMsg() function?

     

    Thank you!

     

    Q

     

     

  • I would do a search on POWER_SAVING define.  This will take you to sleep decision.

    -Greg

    -

  • I think the quickest way is to take a look to a file like SimpleBLEPeripheral.c

     

    static void simpleBLEPeripheral_ProcessOSALMsg( osal_event_hdr_t *pMsg )

    {

      switch ( pMsg->event )

      {

      #if defined( CC2540_MINIDK )

        case KEY_CHANGE:

           // simpleBLEPeripheral_HandleKeys( ((keyChange_t *)pMsg)->state, ((keyChange_t *)pMsg)->keys );

           //- comment the line of code above and put your code here

           break;

      #endif // #if defined( CC2540_MINIDK )

          

      default:

        // do nothing

        break;

      }

    }

     

    Also, as defined in osal osal_pwrmgr.h:

    /* With PWRMGR_ALWAYS_ON selection, there is no power savings and the

     * device is most likely on mains power. The PWRMGR_BATTERY selection allows

     * the HAL sleep manager to enter SLEEP LITE state or SLEEP DEEP state.

     */

    #define PWRMGR_ALWAYS_ON  0

    #define PWRMGR_BATTERY    1

     

    This is used for example in osal.c when deciding if return to sleep mode when there are no events pendent to manage:

    #if defined( POWER_SAVING )

      else  // Complete pass through all task events with no activity?

      {

        osal_pwrmgr_powerconserve();  // Put the processor/system into sleep

      }

    #endif

     

    Bye and good luck.

  • Hi All ,

    I want to wakeup CC2541 chip using Accelerometer sensor . How I would achieve this can anyone suggest the way? Accelerometer sensor cnnected to P0.2 pin