cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Smart Bluetooth

Anonymous
Not applicable

Based on various parameters in my application, I would like to switch between timed and untimed DEEP SLEEP.  I am always using an interrupt to wake up on, sometimes combined with a timer and other times without a timer.  The first DEEP SLEEP after a POWER ON RESET, always results in a DEEP SLEEP without a timer.  Afterwards, based on parameters set at connection, I attempt to use the DEEP SLEEP with a timer, but the CHIP never wakes up with the timer once I use it without the timer.   If i always set the timer (make sure secs < SLEEP_MAX), then the CHIP will wakeup with the timer without issue over and over again.  Can someone tell me what I should be doing different, after a DEEP SLEEP without a timer, that will allow the CHIP to wake up with the TIMER as expected?

-----snip-----

void

app_enter_deep_sleep_with_timer(int secs)

{

     ble_trace0("+Entering deep sleep");

     devLpmConfig.disconnectedLowPowerMode = DEV_LPM_DISC_LOW_POWER_MODES_HID_OFF;

     miaDriverConfig.delayAfterEnteringHidOffInUs= 30000000; // 700000;

     devLpmConfig.wakeFromHidoffRefClk = HID_OFF_TIMED_WAKE_CLK_SRC_128KHZ;

     if (secs < SLEEP_MAX){

       devLpmConfig.wakeFromHidoffInMs = secs * 1000;

       ble_trace1("LPM timer secs %d", secs);

     } else {

         devLpmConfig.wakeFromHidoffInMs = 0;

     }

     gpio_inputDisableAll();

     gpio_configurePin(GPIO_PIN_P0 / 16, GPIO_PIN_P0 % 16, GPIO_INPUT_ENABLE | GPIO_PULL_UP, 0);

     mia_enableLhlInterrupt(1);

     gpio_configurePin(GPIO_CAP_BUTTON / 16, GPIO_CAP_BUTTON % 16, GPIO_INPUT_ENABLE | GPIO_EN_INT_BOTH_EDGE, 0);

     devlpm_enableWakeFrom(DEV_LPM_WAKE_SOURCE_GPIO);

     bleprofile_PrepareHidOff();  // Puts device into Deep Sleep ~1.33uA

}

-----snip-----

0 Likes
1 Solution
Anonymous
Not applicable

I set up my prep to sleep code exactly in the same order as your example, and I still had the same issue.  Our code is proprietary so I can't post it to a public forum..  Looks like the issue is occurring either from a hardware or some other firmware reason.  I think I will have to shelve this issue for now.  Thanks for the help!

View solution in original post

0 Likes
12 Replies
BoonT_56
Employee

Deep sleep can be configured to wake up with an internal clock from 64ms to 36hours. Below is a thread

with a lot of details on this topic. Hope it helps.

Sleep Deep_Sleep Explanation and Techniques

0 Likes
Anonymous
Not applicable

Thanks for the help.  However, I had no problem getting my chip to go into DEEP SLEEP with a WAKE_UP from the LPO Internal Clock (TIMER) as well as either 1 or 7 GPIO INTERRUPTS.  The issue that I have is, I try to WAKE_UP sometimes from JUST the GPIO_INTERRUPT and sometimes from  BOTH the TIMER and the GPIO_INTERRUPT, but once I set it to JUST the GPIO_INTERRUPT, I can never get it to WAKE_UP from the TIMER again.

0 Likes
BoonT_56
Employee

cliff@rayman.com

Did you have a chance to review the rtc_sample.c app?

0 Likes
Anonymous
Not applicable

boont / jamesle1

Yes, I have.  I had used it in the past to isolate an issue with the RTC, that occurred after waking up from DEEP SLEEP.  The DEEP SLEEP their works fine, as it does in my APP, as long as the DEEP SLEEP is ALWAYS TIMED.  It is only when I am trying to swtich from NON-TIMED to a TIMED wakeup, that I have an issue.

0 Likes
BoonT_56
Employee

I will have to take this back to the factory to find out whether the wake-up scheme can be switched.

0 Likes
Anonymous
Not applicable

Can the wake-up scheme be switched or once you set it, does it stay for some reason without change?

0 Likes
JacobT_81
Employee

Hi cliff@rayman.com

I'm unable to reproduce this problem. I wrote a sample app based on your snip above. I was able to toggle in between wake sources multiple times back and forth: from strictly GPIO and then from both GPIO+Timer.

I studied the low-level deep-sleep code and didn't find anything that could be causing the behavior you describe.

Are you able to consistently reproduce this?

Jacob

Anonymous
Not applicable

Hi Jake,

Can you do me a favor and send your sample App?  I will test it.  If it works correctly for me also, I will work to determine what is different about my App and your App.  I am always watching for a button event (interrupt), and then either using the timed or non-timed DEEP SLEEP.  Hopefully your App is working and I can make mine work like yours.

Thanks!

0 Likes
JacobT_81
Employee

Hi cliff@rayman.com

The app is attached below.

It's just hello_sensor with your snip worked in--putting the chip to sleep immediately at the end of the create function. The only change I made in your snip was the method by which I toggle between wake sources. I use GPIO0 as a push button input. If in the create function the pin is high I wake from GPIO and from timer, if during a sequential boot (a.k.a. wake from deep sleep) it is held low, I wake only from GPIO.

See line 478 - 506 of hello_sensor.c.

Jacob

0 Likes
Anonymous
Not applicable

Hi Jake,

I was able to get your code working without issue.  I put all of the sleep code in the same order that you had yours in, but mine still fails.  Once I use the " devLpmConfig.wakeFromHidoffInMs=0", then the chip will not wake up again with the timer.   Not sure what would cause it.

-----snip-----

void

app_enter_deep_sleep_with_timer(int secs)

{

  ble_trace1("Entering deep sleep %d", secs);

  //record time before going to sleep

  UINT32 time_before_sleep;

  time_before_sleep = TimeGet32();

  ble_trace1("Write time_before_sleep %d", time_before_sleep);

  bleprofile_WriteNVRAM(NVRAM_TIMERCAP_TIME_BEFORE_SLEEP, 4, &time_before_sleep);

  turnLedOff();  //ensure we caught the last OFF

#ifdef USE_ADC

  UINT32 state = adc_setPower(ADC_POWER_DOWN);

  gpio_configurePin(GPIO_PIN_P15 / 16, GPIO_PIN_P15 % 16, GPIO_INPUT_DISABLE, 0);

#endif

  ble_trace1("End RAM %d bytes", cfa_mm_MemFreeBytes());

  // Configure the low power manager to enter deep sleep.

  devLpmConfig.disconnectedLowPowerMode = DEV_LPM_DISC_LOW_POWER_MODES_HID_OFF;

  miaDriverConfig.delayAfterEnteringHidOffInUs= 30000000; // 700000;

  devLpmConfig.wakeFromHidoffRefClk = HID_OFF_TIMED_WAKE_CLK_SRC_128KHZ; // OR external: HID_OFF_TIMED_WAKE_CLK_SRC_32KHZ.

  // Configure the wake time in mS. This here is 24Hrs.

  int deep_sleep_secs = 0;

  if( secs < SLEEP_MAX){

  deep_sleep_secs = secs * 1000;

  }

  devLpmConfig.wakeFromHidoffInMs = deep_sleep_secs;

  ble_trace1("wakeFromHidoffInMs: %d", deep_sleep_secs);

    // disable all input, then set the pins we need to configure for sleep.

  gpio_inputDisableAll();

  gpio_configurePin(GPIO_PIN_P0 / 16, GPIO_PIN_P0 % 16, GPIO_INPUT_ENABLE | GPIO_PULL_UP, 0);

  mia_enableLhlInterrupt(1);

  gpio_configurePin(GPIO_CAP_BUTTON / 16, GPIO_CAP_BUTTON % 16, GPIO_INPUT_ENABLE | GPIO_EN_INT_BOTH_EDGE, 0);

  devlpm_enableWakeFrom(DEV_LPM_WAKE_SOURCE_GPIO);

  bleprofile_PrepareHidOff(); // devlpm_enterLowPowerMode();

}

-----snip-----

0 Likes
JacobT_81
Employee

What hardware are you using? If you send your code I can test on my end and see if I can spot anything in the code. It's difficult to debug until I can reproduce it.

You can either post it or send to community-manager@cypress.com​.

Jacob

0 Likes
Anonymous
Not applicable

I set up my prep to sleep code exactly in the same order as your example, and I still had the same issue.  Our code is proprietary so I can't post it to a public forum..  Looks like the issue is occurring either from a hardware or some other firmware reason.  I think I will have to shelve this issue for now.  Thanks for the help!

View solution in original post

0 Likes