cancel
Showing results for 
Search instead for 
Did you mean: 

USART_ISR_WUF is not set after wake up from STOP2 by LPUART

Charles_Li
Associate II

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?

Charles_Li_0-1733991734504.png

 

0 REPLIES 0