cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5 wakeup from stop mode with LPUART

andreas23
Associate II

Hello.

I'm trying to wakeup the STM32U5 controller (U575ZI Nucleo board) when a byte is received using the LPUART.

I'm using the LSE clock for the LPUART. Without entering the stop mode, the LPUART interrupt is triggered whenever a byte is received. This is working fine.

But when I enter the stop mode, I'm not able to wakeup the controller with the LPUART. Using the Userbutton as wakeup source is working.

The reference manual shows the "lpuart_wkup" output signal in the block diagram. But there is now further description about this signal and how it is enabled. Other STM32 controllers (like the STM32L4) have a dedicated WUFIE interrupt bit which can be enabled.

0693W00000WJbwhQAD.png 

How do I enable the wakeup signal for the LPUART on STM32U5 controllers. Can you help me please.

Thanks,

Andreas

11 REPLIES 11
Bubbles
ST Employee

Hi @andreas23​,

what stop mode are you using? In RM0456 table 89 you can see that LPUART can only wake the MCU from Stop1 and Stop2, not from Stop3.

BR,

J

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

andreas23
Associate II

I tried Stop0, Stop1 and Stop2. But I wasn't able to exit any of these stop modes with the LPUART.

I see. Did you enable the UESM bit in the CR1?

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

andreas23
Associate II

Yes I did. The CR1 register is set to 0x2F (RXNEIE, TE, RE, UESM, UE). I know it is hard for you to help. Maybe, you have an example which demonstrates the wakeup from stop mode with the LPUART?

Yes I did enable the UESM bit in the CR1 register. Is this bit responsible for the lpuart_wkup line of the block diagram?

Do I need to configure something else to enable the lpuart_wkup line. Is there something I have to enable in the PWR module? To use the user button for the wakeup I had to enable the wakeup pin. Is there something similar for the LPUART?

nilesh-dryad
Associate III

Hi,

Did you enabled the LPUART clock in sleep mode and UESM bit?

You can do that by calling following.

__HAL_RCC_LPUART1_CLK_SLEEP_ENABLE();

HAL_UARTEx_EnableStopMode(&lpuart1);

It worked for me.

Hi,

I already had the UESM bit enabled and also the clock in sleep mode.

Have you tried this with the LPUART or with any other USART? Because I tested it right now with the USART2 and used the HSI clock for it. And the USART2 is able to wakeup the controller from Stop0 and Stop1 mode as expected.

Could you eventually show me the full LPUART initialization code? Thanks

nilesh-dryad
Associate III

Hi,

I am using LPUART but I am not using LSE for LPUART. I am using HSI for the LPUART.

In fact I am using UART1, UART2, UART3 and LPUART1 in STOP1 mode.

I am using GPDMA with Receive IDLE interrupt.

Note that if you are using GPDMA, you also need to enable GPDMA clock in Sleep mode.

And If you are usig HSI then you need to enable HSI in stop mode which I guess you already did because UART2 is working in your case.

You can also take configuration from LPUART_LPBAM example in Cube. Just LPUART configuration.

FM.1
Associate III

Hi @andreas23​ do you use the HAL? HAL_UARTEx_WakeupCallback is triggered when a character is received when preparing the stop mode with the code below. Do not forget the WUFIE in CR3! This is missing in the HAL implementation but can be configured through LL_LPUART_EnableIT_WKUP.

(I'm using the LSE clock with a LPUART1 and a stm32l476rg)

void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart) {
	ITM_SendChar('V');
}
 
__weak void PreSleepProcessing(uint32_t ulExpectedIdleTime)
{
	UART_WakeUpTypeDef WakeUpSelection = {
		.WakeUpEvent = UART_WAKEUP_ON_READDATA_NONEMPTY
	};
	HAL_StatusTypeDef res = HAL_UARTEx_StopModeWakeUpSourceConfig(&hlpuart1, WakeUpSelection);
	if (HAL_OK != res) {
		Error_Handler();
	}
 
	HAL_SuspendTick();
	res = HAL_UARTEx_EnableStopMode(&hlpuart1);
	if (HAL_OK != res) {
		Error_Handler();
	}
 
	res = HAL_UARTEx_EnableClockStopMode(&hlpuart1);
	if (HAL_OK != res) {
		Error_Handler();
	}
 
	LL_LPUART_EnableIT_WKUP(hlpuart1.Instance);
 
	__asm volatile( "dsb" ::: "memory" );
	HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
	__asm volatile( "isb" );
}