2025-02-04 06:22 AM - edited 2025-02-04 06:23 AM
I am working on a low power mode in a freeRTOS ble application. On a user request the device is to go into low power mode Stop2.
In order to achieve the lowest power consumption ~2µA (stm32wb55) the ble activity has to be deactivated and the cpu1 & cpu2 has to go into lp-mode.
In order to deactivate the ble antenna hci_reset is used. The low power mode implemented with hci_reset() works when tested on a Nucleo-STM32wb55 board based on the BLE_HeartRateFreeRTOS example. When I set it up on another project the hci_reset deletes all threads and doesn't excecute the the rest of the LP sequence.
Here is the setup so far:
void LowPowerThread(void *argument)
{
HAL_EnableDBGStopMode();
for (;;) {
osDelay(5000);
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_RESET); /* Turn off DEBUG LED */
hci_reset(); /* resets the Link Layer on an LE Controller (ble_hci_le.h) */
LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
/* Disable SysTick Interrupt */
CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
HAL_SuspendTick(); /* suppend TIM17 */
LL_EXTI_DisableIT_0_31(LL_EXTI_LINE_ALL_0_31 & ~(LL_EXTI_LINE_6)); /* Disable all interrupts except from WakeUp Pin*/
LL_EXTI_DisableIT_32_63(LL_EXTI_LINE_ALL_32_63);
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
/* ... STOP Mode ... */
HAL_ResumeTick();
SYSCLKConfig_FromSTOP();
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_SET); /* Turn on DEBUG LED */
}
}
Here is a screenshot before the hci_reset command is called and after.
Before:
OBS: here the LowPowerThread is called RelibableJourney
After:
Any guidance in understanding how the hci_reset() can delete threads and thereby omit the excecution of code in a thread is greatly appreciated