2023-10-26 10:31 PM
Hello all,
I am working with the LBAD0ZZ1SE module, also used on the B-L462E-CELL1.
I successfully adapted the "Nx_TCP_Echo_Client" Sample from X-Cube_cellular 7.1.0 to fit my needs but right now am stuck at the final step, which is the low power mode.
I configured ThreadX for low power:
And implemented the following functions:
/**
* @brief App_ThreadX_LowPower_Enter
* @PAram None
* @retval None
*/
void App_ThreadX_LowPower_Enter(void)
{
/* USER CODE BEGIN App_ThreadX_LowPower_Enter */
ULONG currentValue = 0;
UINT ret;
tx_semaphore_info_get(&mainSemaphore, NULL, ¤tValue, NULL, NULL, NULL);
ret = tx_semaphore_get(&mainSemaphore, TX_NO_WAIT);
if (ret == TX_SUCCESS)
{
HAL_GPIO_WritePin(SWITCH_GPIO_Port, SWITCH_Pin, GPIO_PIN_RESET);
printf("go to sleep\r\n");
/* Enter to the stop mode */
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 60, RTC_WAKEUPCLOCK_CK_SPRE_16BITS);
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
}
/* USER CODE END App_ThreadX_LowPower_Enter */
}
and
/**
* @brief App_ThreadX_LowPower_Exit
* @PAram None
* @retval None
*/
void App_ThreadX_LowPower_Exit(void)
{
/* USER CODE BEGIN App_ThreadX_LowPower_Exit */
HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
SystemClock_Config();
HAL_ResumeTick();
HAL_GPIO_WritePin(SWITCH_GPIO_Port, SWITCH_Pin, GPIO_PIN_SET);
if(tx_semaphore_put(&sleepSemaphore)== TX_SEMAPHORE_ERROR){
while(1){
//HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
HAL_Delay(1000);
}
}
/* USER CODE END App_ThreadX_LowPower_Exit */
}
I noticed in the docs for the package:
"To support low power, the application must close the socket before entering low-power mode."
Which I respected at the end of my application.
nxd_mqtt_client_delete(&mqtt_client);
nx_dns_delete(DnsClientPtr);
UINT ret = nx_ip_delete(p_IpInstance);
So there should be now open sockets.
But still the board does not seem to go to sleep.
I use the StLink-V3-PWR and am measuring this current draw from startup to "sleep".
Any help or ideas would be greatly aprreciated.