- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've been trying to get deep sleep functionality to work on a PSoC module and have not been able to get it to operate correctly. My intended code flow is to do the following:
- Come out of hibernate with a button press
- Connect to a BLE host
- Configure sensors and watchdog and go into deep sleep loop
- Waking up via watchdog every 5/30 seconds to read and send data over BLE then going back to deep sleep
- Return to hibernate when BLE is disconnected for a set amount of time
The hibernate functionality works fine but the MCU locks up whenever I try to enter deep sleep. I pulled a HandleLowPowerMode function out of a project similar to this one (http://www.cypress.com/blog/100-projects-100-days/project-027-ble-power-consumption-optimization) but it hasn't worked correctly. I also tried speedycat's EasySleep library (http://www.cypress.com/forum/psoc-4-ble/library-called-easysleep) to the same result.
When I use HandleLowPowerMode without the CyEnterCriticalSection function calls, the deep sleep loop actually works but causes the BLE to drop. From what I saw in the documentation (and an example project), the BLE connection should remain active through the deep sleep call unless I missed something.
void HandleLowPowerMode(uint8 lpmSel)
{
CYBLE_LP_MODE_T sleepMode;
CYBLE_BLESS_STATE_T blessState;
uint32_t interruptStatus;
if (lpmSel == DEEPSLEEP)
{
sleepMode = CyBle_EnterLPM(CYBLE_BLESS_DEEPSLEEP);
blessState = CyBle_GetBleSsState();
interruptStatus = CyEnterCriticalSection();if(sleepMode == CYBLE_BLESS_DEEPSLEEP)
{
if(blessState == CYBLE_BLESS_STATE_ECO_ON || blessState == CYBLE_BLESS_STATE_DEEPSLEEP)
{
LCLK_Write(LOW);
UART_UartPutString("Entering Deep Sleep...");
UART_UartPutString("\n");
CyDelay(10);
CySysPmDeepSleep();
}
}
else if (blessState != CYBLE_BLESS_STATE_EVENT_CLOSE)
{
UART_UartPutString("Entering Sleep...");
UART_UartPutString("\n");
CyDelay(10);
CySysClkWriteHfclkDirect(CY_SYS_CLK_HFCLK_ECO);
CySysClkImoStop();
CySysPmSleep();
CySysClkImoStart();
CySysClkWriteHfclkDirect(CY_SYS_CLK_HFCLK_IMO);
}
else
{}
CyExitCriticalSection(interruptStatus);
}}
I have the project attached in addition to the above code block. Any assistance would be appreciated!
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Check out this information it explains the sleep and power reduction issues.