DA14683: Implementing a "soft power button". Push to sleep. Push again to wake.

Hardware:

Custom DA14683 Board.

SDK 1.0.14.1081 (last updated in 2018)

Situation:

I need to implement a "soft power button".   This is a button that has the same user functionality as a physical power switch would have, but operates internally by initiating sleep/wake.  Push it to "turn off" the product.  Push it again to "turn on" the product.  Power consumption should be minimal in "powered off" mode.

The button on the DA14683 board is already working, and I can get a notification that it was pressed when the system is running, but I am unable to get the system to fully go to sleep permanently (it still wakes periodically), and I am unable to get the system to wake up from a button press when it is asleep.  

I also need the USB charging to either work while the system is sleeping, or wake the system when a USB cable is inserted.

 

Requirements:

1) If the system is powered on and operating:  when the button is pressed, the system should halt all operations and go into a low power sleep mode and not wake on it's own.  

2) If the system is sleeping: when the button is pressed, the system should power back up.  (Acceptable to do a full device reset)

3) If the system is sleeping: when the USB cable is plugged in, the system should ideally remain sleeping and charge the battery.  It is also acceptable for the insertion of a USB cable to wake the system and then start charging.

4) It is acceptable, and probably preferable, to have the system do a full reset when it comes out of sleep.  This makes the requirements for retaining memory much easier because I don't need to retain anything.

Questions:

1) Are there any demos that have the functionality of putting the system into sleep with the push of a button, and only having the system wake back up if the button is pushed again?

2) How do you wake the system when a USB cable is inserted?

3) Is there a way to "Force" the system to stop all operations and go to sleep without waking itself up periodically?  As I said, I don't need to retain any state since I can do a full system reset when the device wakes up.  The only requirements for functionality while it's asleep is to wake back up only if the button is pressed or if the USB cable is inserted.

Parents
  • Hi Nathan, 

    1. We don't have any particular demo for the described functionality, but you can check the following tutorial : http://lpccs-docs.renesas.com/da1468x_external_interruption/implementation.html#configure-the-gpio-generating-interruption

    - You will need to configure the wake-up controller and in the callback function put it into sleep mode. 

    - Of course, before putting into sleep mode, you should first stop advertising by calling the ble_gap_adv_stop() API.

    - When the device stops advertising, you will get an BLE_EVT_GAP_ADV_COMPLETED event. This event can be handled in the for(;;) look : 

    case BLE_EVT_GAP_ADV_COMPLETED:
                           handle_evt_adv_completed_req((ble_evt_gap_adv_completed_t *) hdr);
                           break;

    - You can also put it to sleep on this function when the advertising is stopped : 

    static void handle_evt_adv_completed_req (ble_evt_gap_adv_completed_t *evt)
    {
            /*put it into sleep*/
    }

    - To wake it up, again you should use the wake-up controller. Please check the tutorial for more info. 

    General conditions that will prevent the device goes to sleep : 

    - the debugger is attached the CPU (like when attaching the J-LINK debugger and stepping through the code)
    - there are any open adapters.
    - there are pending FLASH write operations
    - there are active tasks

    General conditions to go to sleep successfully : 

    - All tasks (except the IDLE task) should be suspended (not running). All the tasks should be in IDLE state.
    - there are NO pending interrupts (put the sensor in sleep/power down mode )
    - there is NO active transaction through the adapters interface
    - there are NO intensive write flash operations
    - the J-LINK debugger is not attached (there is no active debugging session)

    QUESTION: which sleep mode you would like to use? hibernation? 

    2. Please refer to the following document, chapter 5.8 : https://www.renesas.com/us/en/document/apn/b-061-application-note-da1468x-application-hardware-design-guidelines?language=en&r=1600761

    If you are using hibernation, you should apply the circuit as described in figure 24. 

    3. As mentioned there are some conditions that you should manage them in your application.

    Best regards, 

    PM_renesas

  • Thank you for the explanation.  I will try shutting down all the adapters and suspending all the tasks.  

    I would like to use Hibernation, but my PCB does not have the circuit as noted to hook the USB 5V up to the GPIO interrupt so I can't wake from hibernation to charge the battery if a USB cable is inserted. 

    Note: anyone making a new PCB, ADD THAT USB WAKE CIRCUIT!

Reply Children
No Data