cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ 6

chha_1641891
New Contributor

Hello

I am programming a function to wake up with the wakeup key after entering PSoC6 deep sleep mode.

Below is the function source.

 

void gotoDeepSleep(void)
{
cy_stc_ble_gap_disconnect_info_t info;
cy_en_ble_api_result_t apiResult;

Cy_GPIO_Clr(M4_TRIGGER_0_PORT, M4_TRIGGER_0_NUM);
Cy_SysLib_Delay(500);

Cy_GPIO_Write(STATUS_LED_0_PORT, STATUS_LED_0_NUM, DISABLE_H);
Cy_SysDisableCM4();
Cy_SCB_SPI_Disable(SPI_AFE_HW, NULL);
UART_DEBUG_PutString(": STOP_M4\r\n");


if(Cy_BLE_GetConnectionState(appConnHandle) == CY_BLE_CONN_STATE_CONNECTED) {
info.reason = CY_BLE_HCI_ERROR_OTHER_END_TERMINATED_USER;
info.bdHandle = appConnHandle.bdHandle;

do {
apiResult = Cy_BLE_GAP_Disconnect(&info);
Cy_SysLib_Delay(100);
Cy_BLE_ProcessEvents();
} while(apiResult != CY_BLE_SUCCESS);

UART_DEBUG_PutString(": Cy_BLE_GAP_Disconnect()\r\n");
}

do {
apiResult = Cy_BLE_Stop();
Cy_SysLib_Delay(100);
Cy_BLE_ProcessEvents();
} while(apiResult != CY_BLE_SUCCESS);

UART_DEBUG_PutString(": Cy_BLE_Stop()\r\n");


UART_DEBUG_PutString(": Enter deep sleep\r\n");
Cy_SysLib_Delay(1500);

UART_DEBUG_Disable();
stop_WDT();

// Enable GPIO wake-up interrupt assigned to CM0+
Cy_SysInt_Init(&SYSTEM_IRQ_cfg, handling_SYSTEM_IRQ);
NVIC_ClearPendingIRQ(SYSTEM_IRQ_cfg.intrSrc);
NVIC_EnableIRQ(SYSTEM_IRQ_cfg.intrSrc);
Cy_SysLib_Delay(100);

// Enter deep sleep mode
Cy_SysPm_DeepSleep(CY_SYSPM_WAIT_FOR_INTERRUPT);
NVIC_SystemReset();
}

 

The sequence of actions is as follows.


1. If pairing is in progress, use the Cy_BLE_GAP_Disconnect() function to disconnect.
2. Turn off BLE.
3. Turn off the UART and watchdog.
4. Register the key as a wake-up interrupt.
5. Enter Cy_SysPm_DeepSleep() mode.
6. When the key is pressed, it wakes up and resets by executing the NVIC_SystemReset() function.

 

When I run this function, It works fine while advertising.
But if this function is executed in pairing state (when the Cy_BLE_GAP_Disconnect() function is executed), it does not wake up after entering deep sleep mode.
Why? Please reply.

thank you.

0 Likes
1 Reply
PratikshaV
Moderator
Moderator

Hi,

Please check that when Cy_BLE_GAP_Disconnect() function is executed in pairing state the peer device is successfully disconnected by printing message on uart terminal and also check for CY_BLE_EVT_GAP_DEVICE_DISCONNECTED event in callback function. And after successful disconnection then enter the system in deepsleep mode and check whether it comes out of deepsleep mode .

OR

Please share your complete project where you are facing this problem so that we can reproduce it from our side.

 

Regards

Pratiksha Vernekar

0 Likes
Top labels