Repetitious Deep Sleep and Wake Up doesn't work correctly.

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

cross mob
Anonymous
Not applicable

Hi

I tried to make my custom board enter Deep Sleep and wake up by GPIO interruption repetitiously.

However, from 2nd Deep Sleep, ADV doesn't work correctly.

When I make my board enter Deep Sleep mode, must any interruption be prohibited?

Only 1 set works correctly but from 2nd Deep sleep, they doesn't work correctly.

I implemented by reading these thread:

How can I make bcm20732s sleep and wake it up by GPIO interrupt?

Re: How can I wake BCM20737S up by using GPIO interrupt?

Source Code: deep sleep enablement and the associated clock source handling...

If there are someone who can repeat them, please show me a part of your source code which is related to Deep sleep and wake up.

Here is my source code (Deep Sleep and Wake Up work correctly only once):

In create():

    // ToDo: Do your initialization on app startup

    //initialize MCP9808 temperature sensor connected to the I2C bus

  devlpm_init();

  devlpm_enableWakeFrom(DEV_LPM_WAKE_SOURCE_GPIO);

  gpio_configurePin(GPIO_INT_PIN/16, GPIO_INT_PIN%16,

  GPIO_EN_INT_RISING_EDGE | GPIO_PULL_DOWN | GPIO_INPUT_ENABLE, GPIO_PIN_OUTPUT_LOW);

void app_interrupt_handler(void* parameter, UINT8 arg)

{

  ble_trace0("Wake up!\n");

    bleprofile_Discoverable(HIGH_UNDIRECTED_DISCOVERABLE, NULL);

  gpio_clearPinInterruptStatus(GPIO_DS_INT_PIN/16, GPIO_DS_INT_PIN%16);

}

void enteringHidOff(void) {

  UINT16 interrupt_handler_mask[3] = {0, (1 << GPIO_DS_INT_PIN%16), 0};

    ble_trace0("Entering DeepSleep - AdvStopped \n");

    // Puts device into DeepSleep ~1.33uA/

    if(devlpm_registeredObjectsApproveHidOff()) {

    ble_trace0("all objects are idle.\n");

    }

  devlpm_init();

  devlpm_enableWakeFrom(DEV_LPM_WAKE_SOURCE_GPIO);

    // Now register the interrupt handler.

    gpio_registerForInterrupt(interrupt_handler_mask, info_float_gpio_interrupt_handler, NULL);

    devLpmConfig.disconnectedLowPowerMode = DEV_LPM_DISC_LOW_POWER_MODES_HID_OFF;

    // Now configure the pin. We will use both edges so that we know when the upper and lower

    // thresholds are crossed.

    // port0 which has P0-P15, port1 which has P16-P31 and port2 which has P32-P39

    gpio_configurePin(GPIO_DS_INT_PIN/16, GPIO_DS_INT_PIN%16,

    GPIO_EN_INT_RISING_EDGE | GPIO_PULL_DOWN | GPIO_INPUT_ENABLE, GPIO_PIN_OUTPUT_LOW);

    gpio_setPinOutput(GPIO_PIN_CHARGE/16, GPIO_PIN_CHARGE%16, 0);

    devlpm_enterLowPowerMode();

}

I'm sorry to bother you due to my poor English skill.

Best regards

0 Likes
1 Solution
Anonymous
Not applicable

During my own preliminary test, P12/13 is okay while P2/P3 failed.

I also don't know the reason and it may need some experts here to explain ^_^

BTW: on my test, GPIO_EN_INT_RISING_EDGE works fine for P13. I also use 20737 TAG3 EVK.

View solution in original post

0 Likes
12 Replies
BoonT_56
Employee
Employee
500 likes received 250 likes received 100 likes received

Could this be a bug in the gpio state?

GPIO state in deep sleep

0 Likes
Anonymous
Not applicable

Hi boont

Thank you for your response.

Of cause, I have already read the thread.

However, my board doesn't wake up from second Deep Sleep.

Is it impossible repetitious Deep Sleep and Wake Up by a bug?

The following part arvinds mentions is the same completely in my code.

-----------------------------------------------------------------------

void application_create(void)

{

    // all other init

    bleprofile_regAppEvtHandler(BLECM_APP_EVT_ENTERING_HIDOFF, (BLECM_NO_PARAM_FUNC)app_enter_hidoff);

    bleprofile_regAppEvtHandler(BLECM_APP_EVT_ABORTING_HIDOFF,(BLECM_NO_PARAM_FUNC)app_abort_hidoff);

}

void app_enter_hidoff(void)

{

    // Do nothing.

}

void app_abort_hidoff(void)

{

    // Do nothing.

}

------------------------------------------------------------------------

I revise my code to enter Deep Sleep mode like following by reference to BCM20736S Sleep Example Firmware .

------------------------------------------------------------------------

bleapputils_delayUs(500);

bleprofile_Discoverable(NO_DISCOVERABLE, NULL);

bleprofile_PrepareHidOff();

------------------------------------------------------------------------


However, this problem is not resolved.

Best regards

0 Likes

I can't for sure pinpoint what could possibly went wrong but I noticed that you are performing this on your customized board. Does this happen also on the tag3 reference board?

0 Likes
Anonymous
Not applicable

Hi boont

Thank you for your response.

I'm going to check it!

By the way, where is P25 on tag3 reference board?

I confirm it implemented as TP7 in circuit diagram but I can't find it on tag3.

Please tell me.

Best regards

0 Likes

It's on the back of the board, next to the coin-cell holder.

TP7.jpg

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Thank you, boont.

I used P25 on the tag3 reference board.

However, there is no difference.

The same problem happens on the tag3 reference board.

When I use GPIO_EN_INT_RISING_EDGE,  board wakes up only once.

When I use GPIO_EN_INT_LEVEL_HIGH and while P25 is HIGH, I can connect LightBlue app once.

I can find my board with LightBlue app for many times. However, from second connection, LightBlue app show an alert which says "Connection Alert: The periperal disconnected while being interrogated."

To check my code, I made a simple app for repetitious Deep Sleep and Wake up named DeepSleep_test.

However, this problem happens, too.

Please check it with attached imageIMG_4388.PNG

And then,I added some code in default source code generated by WICED Smart Designer like following.

I wrote the code I added only.

In DeepSleep_test_db.h

#define GPIO_PORT(x) (x/16)

#define GPIO_PIN(x) (x%16)

#define GPIO_INT_PIN 25

#define GPIO_INT_SETTING (GPIO_INPUT | GPIO_INIT_LOW | GPIO_INT)

In DeepSleep_test_db.c

const BLE_PROFILE_GPIO_CFG deepsleep_test_gpio_cfg =

{

     {

          GPIO_INT_PIN

     },

     {

          GPIO_INT_SETTING

     }

}

In DeepSleep_test.c

#include  "devicelpm.h"

void deepsleep_test_gpio_interrupt_handler(void* parameter, UINT8 arg);

void app_enter_hidoff(void);

void app_abort_hidoff(void);

void deepsleep_test_create(void) {

    UINT16 interrupt_handler_mask[3] = {0, 0, 0};

   

     devlpm_init();

     devlpm_enableWakeFrom(DEV_LPM_WAKE_SOURCE_GPIO);

   

     interrupt_handler_mask[GPIO_PORT(GPIO_INT_PIN)] |= (1 << GPIO_PIN(GPIO_INT_PIN));

     gpio_registerForInterrupt(Interrupt_handler_mask, deepsleep_test_gpio_interrupt_handler, NULL);

     gpio_configurePin(GPIO_PORT(GPIO_INT_PIN), GPIO_PIN(GPIO_INT_PIN), GPIO_EN_INT_LEVEL_HIGH, GPIO_PIN_OUTPUT_LOW);

}

void deepsleep_test_gpio_interrupt_handler(void* parameter, UINT8 arg) {

}

void app_enter_hidoff(void) {

}

void app_abort_hindoff(void) {

}

void deepsleep_test_connection_down(void) {

     bleapputils_delayUs(500);

     bleprofile_Discoverable(NO_DISCOVERABLE, NULL);

     bleprofile_PrepareHidOff();

}

Could you test in your environment this source code?

Best regards.

0 Likes
Anonymous
Not applicable

Can you please try P13 instead of P25 to see if this issue still happen?

Some other suggestions:

try to set DEEPSLEEP_TEST_FINE_TIMER to 1000.

Suggest to simplify the code to test deep sleep only.

Please refer to rtc_sample in SDK  and many other discussions here on how to enter deep sleep and wake up.

thanks.

0 Likes
Anonymous
Not applicable

Hi @roger_lu

Thank you for your response.

I used P13 instead of P25.

It seemed this problem doesn't happens in the case of using GPIO_INT_EN_LEVEL_HIGH only.

However, in the case of GPIO_INT_EN_RISING_EDGE is not resolved.

By the way, why does P13 work differently?

And then, In my custom board, P13 is used for the other function.

So, please tell me the GPIO which works like P13.

Best regards

0 Likes
Anonymous
Not applicable

During my own preliminary test, P12/13 is okay while P2/P3 failed.

I also don't know the reason and it may need some experts here to explain ^_^

BTW: on my test, GPIO_EN_INT_RISING_EDGE works fine for P13. I also use 20737 TAG3 EVK.

0 Likes
Anonymous
Not applicable

Hi roger_lu

Thanks to you, I could resolve this problem.

I decided to use P0 for GPIO interruption.

In the case of P24, P25, P32, P33, I couldn't confirm that my board wakes up correctly with the tag3 reference board.

In my board, I can't use P13. So, finally I decided to use P0.

All of my cases are  GPIO_EN_INT_LEVEL_HIGH.

I'm sorry for not checking the case of GPIO_EN_INT_RISING_EDGE.


>BTW: on my test, GPIO_EN_INT_RISING_EDGE works fine for P13. I also use 20737 TAG3 EVK.

I'm sorry for my mistake.

In the case of P0 and P13, I confirm that both GPIO_EN_INT_RISING_EDGE and GPIO_EN_INT_LEVEL_HIGH works correctly.

Hi boont

Are there any differences from GPIOs?

Why doesn't the interruption of P24, P25, P32 and P33 work?


Best regards

0 Likes
Anonymous
Not applicable

Hi, Gell,

If possible, please try NOT to use P0 to wake up.

You can find many threads here that mentioned P0 may affect the deep sleep mode.

And it is suggested to connect P0 to GND through a resistor.

0 Likes
Anonymous
Not applicable

Hi boont

>I can't for sure pinpoint what could possibly went wrong but I noticed that you are performing this on your customized board. Does this happen also on the tag3 reference board?

I checked this on tag3 board.

However, there is no difterence.

So, my answer to your question is YES.

This happens on the tag3 reference board, too.

Best regards

0 Likes