2024-12-12 12:22 AM - edited 2024-12-12 12:24 AM
I've enabled STOP2 mode with the below code statement
void PWR_EnterStopMode(void)
{
/* USER CODE BEGIN PWR_EnterStopMode_1 */
UART_WakeUpTypeDef WakeUpSelection;
WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_STARTBIT;
if (HAL_UARTEx_StopModeWakeUpSourceConfig(&hlpuart1, WakeUpSelection)!= HAL_OK)
{
Error_Handler();
}
__HAL_UART_ENABLE_IT(&hlpuart1, UART_IT_WUF);
HAL_UARTEx_EnableStopMode(&hlpuart1);
/* USER CODE END PWR_EnterStopMode_1 */
/**
* When HAL_DBGMCU_EnableDBGStopMode() is called to keep the debugger active in Stop Mode,
* the systick shall be disabled otherwise the cpu may crash when moving out from stop mode
*
* When in production, the HAL_DBGMCU_EnableDBGStopMode() is not called so that the device can reach best power consumption
* However, the systick should be disabled anyway to avoid the case when it is about to expire at the same time the device enters
* stop mode (this will abort the Stop Mode entry).
*/
HAL_SuspendTick();
/**
* This function is called from CRITICAL SECTION
*/
EnterLowPower();
/************************************************************************************
* ENTER STOP MODE
***********************************************************************************/
LL_PWR_SetPowerMode(LL_PWR_MODE_STOP2);
LL_LPM_EnableDeepSleep(); /**< Set SLEEPDEEP bit of Cortex System Control Register */
/**
* This option is used to ensure that store operations are completed
*/
#if defined (__CC_ARM)
__force_stores();
#endif
__WFI();
/* USER CODE BEGIN PWR_EnterStopMode_2 */
/* USER CODE END PWR_EnterStopMode_2 */
return;
}
/**
* @brief Exits Low Power Stop Mode
* @note Enable the pll at 32MHz
* none
* @retval none
*/
void PWR_ExitStopMode(void)
{
/* USER CODE BEGIN PWR_ExitStopMode_1 */
/* USER CODE END PWR_ExitStopMode_1 */
/**
* This function is called from CRITICAL SECTION
*/
ExitLowPower();
HAL_ResumeTick();
/* USER CODE BEGIN PWR_ExitStopMode_2 */
HAL_UARTEx_DisableStopMode(&hlpuart1);
/* USER CODE END PWR_ExitStopMode_2 */
return;
}
LPUART could wake up MCU that I verifed by set a break point on
void LPUART1_IRQHandler(void)
But USART_ISR_WUF is not set causing I can't handle RX message after resuming from STOP2 mode, is there anything I missed?
2024-12-13 11:51 AM
Hello @Charles_Li ,
This post has been escalated to the ST Online Support Team for additional assistance. We'll contact you directly.
Regards,
Roger
2024-12-20 07:28 AM - edited 2024-12-20 07:57 AM
Hello @Charles_Li @Roger SHIVELY
I have exactly the same problem,
The frame is processed only when the MCU exits STOP2 mode.
I have the impression that the problem comes from the LPUART==>ISR==> IDLE bit which seems hardware and takes a while to go from 0 to 1.
I added a small delay right after the interrupt and everything works perfectly, but I don't think it's the best solution.
Very roughly, I tried a while loop
while (LL_LPUART_IsActiveFlag_IDLE(LPUART1) == 0)
{
}
This allowed me to understand that the problem was indeed coming from the LPUART==>ISR==> IDLE flag which was triggered a little after the IDLE interruption of my DMA.
@Roger SHIVELY have you a solution?
Regards,
Fabien,