bcm20736 deep sleep

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

we are working on the BCM20736 sleep with RTC sample, please see below example.

My question is it seems reset when it goes into deep sleep with wake after 5s. we set the wake time is 5 seconds, the program goes to rtc_sample_create() function again when the timer is out, is it normal?

Also what does the current consumption should be when set it to sleep mode(DEV_LPM_DISC_LOW_POWER_MODES_SLEEP), in our test, it seems the current is more than 3 mA using sleep mode, is it correct?

@

/******************************************************

*               Variables Definitions

******************************************************/

// Following structure defines UART configuration

const BLE_PROFILE_PUART_CFG rtc_sample_puart_cfg =

{

    /*.baudrate   =*/ 115200,

    /*.txpin      =*/ GPIO_PIN_UART_TX,

    /*.rxpin      =*/ GPIO_PIN_UART_RX,

};

/******************************************************

*               Function Definitions

******************************************************/

// Application initialization

APPLICATION_INIT()

{

    bleapp_set_cfg(NULL, 0, NULL, (void *)&rtc_sample_puart_cfg, NULL, rtc_sample_create);

}

// Create the RTC sample.

void rtc_sample_create(void)

{

    RtcTime current_time;

  char buffer[64];

    ble_trace0("rtc_sample_create()\n");

    if (!mia_isResetReasonPor())

    {

    ble_trace0("Waking from deep sleep because the timer went off or a GPIO triggered while waiting for timer to expire.");

    }

    else

    {

    ble_trace0("Not a timed wake.");

    }

    // Always clear interrupts on P39, which is the interrupt pin used by the wake-from-deep-sleep HW block.

    gpio_clearPinInterruptStatus(GPIO_PIN_P39 / GPIO_MAX_NUM_PINS_PER_PORT, GPIO_PIN_P39 % GPIO_MAX_NUM_PINS_PER_PORT);

    blecm_configFlag |= BLECM_DBGUART_LOG;

    bleprofile_Init(bleprofile_p_cfg);

  // If we need to use the external 32K, then configure the reference

  rtcConfig.oscillatorFrequencykHz = RTC_REF_CLOCK_SRC_32KHZ;

  // Since the 32K external LPO is connected tp P10, P11, P12, P26 and P27,

  // input and putput disable all 5 GPIOs.

  gpio_configurePin(0, 10, GPIO_INPUT_DISABLE, 0);

  gpio_configurePin(0, 11, GPIO_INPUT_DISABLE, 0);

  gpio_configurePin(0, 12, GPIO_INPUT_DISABLE, 0);

  gpio_configurePin(1, 10, GPIO_INPUT_DISABLE, 0);

  gpio_configurePin(1, 11, GPIO_INPUT_DISABLE, 0);

    // Initialize the RTC.

    rtc_init();

    memset(buffer, 0x00, sizeof(buffer));

  ble_trace0("Time base is:");

  // RtcTime of 0x00 is the start of RTC time.

    memset(&current_time, 0x00, sizeof(current_time));

  rtc_ctime(&current_time, buffer);

  ble_trace0(buffer);

  // Let year = 2014.

  current_time.year = 2014;

  // Let month = july = 6 (jan = 0)

  current_time.month = 6;

  // Let day = 1st.

  current_time.day = 15;

  // Let current time be 12:00:00 Noon.

  current_time.hour = 12;

  current_time.minute = 00;

  current_time.second = 0x00;

  // If this is a power-on reset, we need to set up the reference time.

  if (mia_isResetReasonPor())

  {

  // Now set the on-chip RTC.

  if(rtc_setRTCTime(&current_time))

  {

  memset(buffer, 0x00, sizeof(buffer));

  ble_trace0("Power-on reset, set current time to:");

  rtc_ctime(&current_time, buffer);

  ble_trace0(buffer);

  }

  else

  {

  ble_trace0("Unable to set time.");

  }

  }

  else

  {

  // Set up the original reference time instead of using 01/01/2010, 00:00:00 as the reference

  // because this is a wake from deep sleep. The HW clock keeps running in deep sleep so when

  // we wake up, the FW needs to know what was used as the original reference time.

  rtc_setReferenceTime(&current_time);

  }

    bleprofile_regTimerCb(rtc_sample_fine_timeout, rtc_sample_timeout);

    bleprofile_StartTimer();

    // Since we have an external 32 KHz LPO, switch to using this during sleep

    // because this will give us a more accurate sleep clock (lower drift than the

    // internal LPO, so the uncertainty window during a receive will be narrower).

    // In general, base sleep current will be lower too.

    // Switching to the external 32K with bleapputils_changeLPOSource without having

    // initialized the RTC, the high-z'ing bonded GPIOs and not having the 32KHz oscillator physically

    // connected to the chip will invoke undefined behavior.

    bleapputils_changeLPOSource(LPO_32KHZ_OSC, FALSE, 250);

    // Trace out number of bytes free.

    ble_trace1("Number of free bytes in RAM: %d",  cfa_mm_MemFreeBytes());

}

// One second timer expired. Read the time from RTC and print.

void rtc_sample_timeout(UINT32 arg)

{

  RtcTime current_time;

  UINT32 seconds_since_time_base;

  char buffer[64];

  tRTC_REAL_TIME_CLOCK raw_clock;

  memset(buffer, 0x00, sizeof(buffer));

  // Get and print current time.

  rtc_getRTCTime(&current_time);

  ble_trace0("Current date/time is:");

  rtc_ctime(&current_time, buffer);

  ble_trace0(buffer);

  // Get and print time since time base in seconds.

  rtc_RtcTime2Sec(&current_time, &seconds_since_time_base);

  ble_trace1("Its been %d seconds since bigbang.", seconds_since_time_base);

  // Get and print the raw 48 bit clock value.

  rtc_getRTCRawClock(&raw_clock);

  ble_trace2("Upper and lower 32 bit values: 0x%08X, 0x%08X\n", raw_clock.reg32map.rtc32[1], raw_clock.reg32map.rtc32[0]);

#ifdef RTC_SAMPLE_ENTER_DEEP_SLEEP_AND_ENABLE_TIMED_WAKE

  {

  static UINT32 num_timeouts_since_boot = 0;

  // Demo going into deep sleep with wake after 5s.

  if (num_timeouts_since_boot++ >= 10)

  {

  // If its been ~10s of ADV, configure timed wake and

  // enter deep sleep right now.

  ble_trace0("Entering deep sleep.");

  gpio_configurePin(0, 0, 0x100, 0);

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

  devLpmConfig.disconnectedLowPowerMode = DEV_LPM_DISC_LOW_POWER_MODES_HID_OFF;

  // Configure the wake time in mS.

  devLpmConfig.wakeFromHidoffInMs = 5000;

  // Configure the reference clock to use.

  // Use the external 32k.

  devLpmConfig.wakeFromHidoffRefClk = HID_OFF_TIMED_WAKE_CLK_SRC_32KHZ;

  gpio_configurePin(0, 0, 0x100, 0);

  // Enter deep-sleep now. Will not return.

  devlpm_enterLowPowerMode();

  }

  }

#endif

}

void rtc_sample_fine_timeout(UINT32 arg)

{

}

0 Likes
1 Solution

Hi Lei,

In deep-sleep mode, all GPIO will be shut down expect the wake-up GPIO, but GPIO still in work status in sleep mode, GPIO can driver out/in current.

BR,

Ocean

View solution in original post

13 Replies
BoonT_56
Employee
Employee
500 likes received 250 likes received 100 likes received

Are you doing this on the tag3? Can you attach a copy of the log file? The below thread

did not encounter this though.

how to config RTC use external 32.768?

Anonymous
Not applicable

We did it on the tag before, it is same behaviour, but now we are working on our board.

what logs do you want? we just run the sample code,  and found some traces like below:

//when power on, it shows:

    ble_trace0("rtc_sample_create()\n");

// enter into deep sleep.

   ble_trace0("Entering deep sleep.");

//then saw the below information again, does that mean reboot?

    ble_trace0("rtc_sample_create()\n");

0 Likes

The RTC sample code in the SDK assumed the use of the ext 32KHz LPO instead of the internal 128KHz. Are you using an external or internal LPO? Let's try it out on the tag3 and proved that it works before trying it out on your board. Can you post the debug trace from the IDE?

zhaohua

0 Likes
Anonymous
Not applicable

we use the external 32KHz LPO.

is the below trace that you want, it is output from HCI UART port. the trace is print in the code

//when power on, it shows:

    ble_trace0("rtc_sample_create()\n");

// enter into deep sleep.

   ble_trace0("Entering deep sleep.");

//then saw the below information again, does that mean reboot?

    ble_trace0("rtc_sample_create()\n");

0 Likes
ZhaohuaS_76
Employee
Employee
25 sign-ins 10 questions asked 10 sign-ins

Hi chenlie,

the program goes to rtc_sample_create() function again when the timer is out, is it normal?

--> it's normal, application image will re-load to RAM if waked up from deep-sleep mode, because the RAM isn't remained in deep-sleep mode.

Also what does the current consumption should be when set it to sleep mode(DEV_LPM_DISC_LOW_POWER_MODES_SLEEP), in our test, it seems the current is more than 3 mA using sleep mode, is it correct?

--> only for 20736, sleep current : about 40uA, deep-sleep current: < 2uA, I suspect the other component consume the power.

BR,

Ocean

0 Likes
Anonymous
Not applicable

Hi Ocean,

Thanks for your reply.

for sleep mode, does the application image will re-load like deep-sleep?if want to enter into sleep mode, just change 'devLpmConfig.disconnectedLowPowerMode =DEV_LPM_DISC_LOW_POWER_MODES_SLEEP', is that right?

Thanks,

Lei Chen

0 Likes

Hi Leichen,

for sleep mode, does the application image will re-load like deep-sleep?

--> no

if want to enter into sleep mode, just change 'devLpmConfig.disconnectedLowPowerMode =DEV_LPM_DISC_LOW_POWER_MODES_SLEEP', is that right?

--> 20736 will enter sleep mode automatically if nothing to do.

BR,

Ocean

Anonymous
Not applicable

Hi Ocean,

It seems our code did not enter sleep, we only use the rtc_sample code in SDK, the current is very big. more than 3ma, any reason will cause that based on your experience.

if 20736 will enter sleep mode automatically, what is the mode 'devLpmConfig.disconnectedLowPowerMode =DEV_LPM_DISC_LOW_POWER_MODES_SLEEP' means?

Thanks,

Lei

0 Likes

Hi Lei,

It seems our code did not enter sleep, we only use the rtc_sample code in SDK, the current is very big. more than 3ma, any reason will cause that based on your experience.

--> Do you test the power consumption only for 20736? or full board?

if 20736 will enter sleep mode automatically, what is the mode 'devLpmConfig.disconnectedLowPowerMode =DEV_LPM_DISC_LOW_POWER_MODES_SLEEP' means?

--> SDK have some code to handle sleep mode, mark the devLpmConfig.disconnectedLowPowerMode to DEV_LPM_DISC_LOW_POWER_MODES_HID_OFF if we need to enter deep-sleep, mark the devLpmConfig.disconnectedLowPowerMode to DEV_LPM_DISC_LOW_POWER_MODES_SLEEP if need to enter sleep mode.

BR,

Ocean

Anonymous
Not applicable

Hi Ocean,

it is board, but why the current in deep sleep mode(uA) is much better sleep mode(mA). we use same way to test current.

Thanks,

Lei

0 Likes

Hi Lei,

In deep-sleep mode, all GPIO will be shut down expect the wake-up GPIO, but GPIO still in work status in sleep mode, GPIO can driver out/in current.

BR,

Ocean

The BCM2073X Supports Multiple Low Power Modes

  • Firmware automatically handles low power states
  • The application may choose to participate in sleep and deep sleep decisions
  • Pause
    • All state information is maintained
    • Near 0 cycle latency to wake up
  • Sleep
    • Used when lower power consumption is required
    • All state information is maintained
    • Can be woken up by timer or GPIO/ Keyscan /Quadrature sensors
    • About 2 mS latency to wake up
  • Deep Sleep
    • No state information is maintained.
    • Can be woken up by GPIO/ Keyscan /Quadrature sensors (~100mS)
    • Includes ability to wake after configured time
      • With internal clock, can wake anywhere from 64mS to ~36 Hrs. With external 32 KHz xtal, 128mS to ~144 Hrs
0 Likes
Anonymous
Not applicable

Hi all,

one more quesiton, we found the RSSI will transmit for serveral seconds after wake up from deep-sleep as slaver, is it normal?

Thanks,

Lei

0 Likes