2021-07-21 02:30 AM
Hi All,
I'm currently working on a project that uses the STM32WB5MMG module.
I did a porting of one of the examples of the repository (BLE_Zigbee_Dyn) for RTOS and everything is working fine.
Now I'm trying to put the MCU in STOPMODE2; a GPIO Interrupt will trigger the enter on STOPMODE.
To manage the stop mode I did this operation
1) I redefined the portSUPPRESS_TICKS_AND_SLEEP function like this
extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );
#define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) if ( getLPModeEnable() == pdTRUE ) { vPortSuppressTicksAndSleep( xExpectedIdleTime );}
in order to be able to avoid entering in sleep mode during normal condition
2) I create a task to manage the interrupt from the GPIO that trigger the STOP MODE
/*TO MANAGE THE SLEEP */
while ((xTaskNotifyWait(0x00,0x00,(uint32_t *)&standby_irq,portMAX_DELAY) != 0) && standby_irq != GO_STANDBY));
prepareStandByMode();
/*TO MANAGE THE WAKEUP*/
while ((xTaskNotifyWait(0x00,0x00,(uint32_t *)&standby_irq,portMAX_DELAY) != 0) && (standby_irq != EXIT_STANDBY));
exitStandByMode();
From the interrupt I simply send a notification to this task in order to enter and exit from the STOPMODE
3) Prepare the system for the standby and the restart after exiting the STOPMODE
/*BEFORE ENTERING LOW POWER MODE*/
taskENTER_CRITICAL();
mainTaskDelete();
HAL_NVIC_DisableIRQ(IPCC_C1_RX_IRQn);
HAL_NVIC_DisableIRQ(IPCC_C1_TX_IRQn);
HAL_NVIC_ClearPendingIRQ(IPCC_C1_RX_IRQn);
HAL_NVIC_ClearPendingIRQ(IPCC_C1_TX_IRQn);
SPI_SENSORS_DeInit();
power_deepsleep_allow();
setLPModeEnable(true);
taskEXIT_CRITICAL();
In mainTaskDelete() I use osThreadTerminate in order to completely terminate the task; I tried also simply suspending the tasks but the result actually didn't change at all.
/*AFTER EXITING LOW POWER MODE*/
taskENTER_CRITICAL();
setLPModeEnable(false);
power_deepsleep_prevent();
Reset_Device_Wrap();
SystemClock_Config();
Init_RTC();
SPI_Sensors_Init();
HAL_NVIC_ClearPendingIRQ(IPCC_C1_RX_IRQn);
HAL_NVIC_ClearPendingIRQ(IPCC_C1_TX_IRQn);
mainTaskCreation();
taskEXIT_CRITICAL();
4) I redefined the two functions configPRE_SLEEP_PROCESSING and configPOST_SLEEP_PROCESSING to manage the enter in STOPMODE2
/*configPRE_SLEEP_PROCESSING*/
if (can_stop) {
LL_RCC_SetClkAfterWakeFromStop(LL_RCC_STOP_WAKEUPCLOCK_MSI);
LL_PWR_SetPowerMode(LL_PWR_MODE_STOP2);
LL_LPM_EnableDeepSleep();
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
}
/* configPOST_SLEEP_PROCESSING */
if (can_stop) {
SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
LL_LPM_EnableSleep();
}
canStop is triggered by power_deepsleep_allow().
The problem that I'm figuring out is that after exiting STOPMODE2, all the radio stack is not working anymore and I can receive an interrupt from IPCC anymore even after the APPE_Init in APP_Entry is executed without any error; I'm wondering if with this type of Low Power Mode there are some operations that I have to do on CPU2 in order to restart it correctly after exiting the power mode
Thanks