2025-11-11 5:39 AM
Hello,
Need information about, does LPUART can wakeup? if the clock source is LSI (32Khz)?
Because I have tried multiple examples to wakeup but it only works in debug mode but not in release mode.
I have also work on optimization level, currently optimization is None for both debug and release.
Thanks,
Nitin
2025-11-11 6:17 AM
Docs say yes:
What examples have you tried? Using HAL, CMSIS, bare metal?
Nucleo board? Custom board? Power supply? ST-LINK attached?
hth
KnarfB
2025-11-11 6:23 AM - edited 2025-11-11 6:30 AM
As per doc, page no 30, LPUART wakeup support only in STOP1 mode not in STOP2 mode. Is that correct ?
Also confuse it say clock source LSI/LSE support, does that mean it does not support HSI to wakeup ?
Edited: Yes it is also shown in the STOP2 mode, but again does it not support to wakeup at HSI clock ?
Using Custom board, HAL library, bare metal, STM32U0 series controller. Connected with 12 volt power supply and ST-Link Debugger for code dump.
2025-11-11 6:33 AM
For more information using, HAL_UARTEx_ReceiveToIdle_IT() for receiving data and transmitting using HAL_UART_Transmit_IT() , So also need to understand does the ReceiveToIdeal support for wakeup event?
Actually I didnt get example code using ReceiveToIdeal() interrupt event.
2025-11-11 6:58 AM
According to the reference manual STM32U0 series advanced Arm<Sup>®</Sup>-based 32-bit MCUs - Reference manual Figure 11. Clock tree, LSI is not an option for LPUART.
KnarfB
2025-11-11 7:20 AM - edited 2025-11-11 7:21 AM
Ohh yes, I was looking at wrong peripheral, I was using HSI.
I'm not sure why the it does not wakeup when rx has some data. Actually I have implement LPTIMER to wakeup at every 2 seconds, so that work perfectly but if RX has data then it dosnt wakeup.
So when lptimer wakeup then it found that RX buffer is filled then it process the RX frame and send the response, then again it wait for lptimer to wakeup again.
During Init()
LPUART1_EXTI_ENABLE_IT() (EXTI->IMR1 |= EXTI_IMR1_IM28)
__HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_HSI);
__HAL_RCC_HSI_ENABLE();
Then if no RX or lptimer then go to stop2 mode
//Preparation for next receive data
RS485_RX_ENABLE();//Its macro to receive RX data on line.
__HAL_UART_FLUSH_DRREGISTER(&hlpuart1);
HAL_UART_AbortReceive(&hlpuart1)
HAL_UARTEx_ReceiveToIdle_IT(&hlpuart1, &gRxBuf[0], UART_RX_BUF_SIZE);
//Below code is to go stop2 mode
__HAL_UART_CLEAR_FLAG(&hlpuart1, UART_CLEAR_PEF | UART_CLEAR_NEF | UART_CLEAR_OREF);
uint32_t dummy = hlpuart1.Instance->RDR; // flush RDR
(void)dummy;
WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_STARTBIT;
if (HAL_UARTEx_StopModeWakeUpSourceConfig(&hlpuart1, WakeUpSelection) != HAL_OK)
{
Error_Handler();
}
while (__HAL_UART_GET_FLAG(&hlpuart1, USART_ISR_BUSY) == SET);
/* make sure that LPUART is ready to receive
* (test carried out again later in HAL_UARTEx_StopModeWakeUpSourceConfig) */
while (__HAL_UART_GET_FLAG(&hlpuart1, USART_ISR_REACK) == RESET);
/* Enable the LPUART Wake UP from STOP mode Interrupt */
__HAL_UART_DISABLE_IT(&hlpuart1, UART_IT_WUF);
__HAL_UART_ENABLE_IT(&hlpuart1, UART_IT_WUF);
/* enter STOP mode */
HAL_UARTEx_EnableStopMode(&hlpuart1);
HAL_SuspendTick();
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
HAL_ResumeTick();
Reset_SystemClock();
HAL_UARTEx_DisableStopMode(&hlpuart1);
Help me to find what I'm missing here?
Thanks,
Nitin
2025-11-11 7:24 AM
Hello @npatil15
According to the reference manual, LPUART wake-up from Stop mode is only supported when either HSI16 or LSE is used as the clock source.