2025-11-17 8:38 AM - edited 2025-11-18 4:03 AM
Hello,
I'm working on a low power project using STM32U073 with FreeRTOS, LPUART2 and LPTIM1.
To achieve the lowest system power possible I am trying to use STOP2 for when the system is idle.
Currently I have LPTIM1 releasing a semaphore every 1 second which then controls an I2C ASIC by grabbing the latest data then setting it going again for the next measurement.
This part of the project works perfectly and will allow the MCU to fall into STOP2, wait for the LPTIM1 compare interrupt, wake the MCU and control the I2C device before then falling back into STOP2.
While the MCU is in RUN mode, caused by LPTIM1, I can successfully service LPUART2 in that it will respond to a 'request for data' Modbus message.
If a message is sent to the MCU while it is in STOP2 the request for data is missed.
For testing I have disabled LPTIM1 IT and am trying to wake the MCU using LPUART RX alone and force the MCU to hold RUN for 100 ms so that I can see it on my power profiler, but all I am seeing is ~2ms activity ( 250 uA spikes on a 150 uA baseline, where I would be expecting an average of 1.16 mA at full power with a successful LPTIM1 wake ) when the MCU is receiving the byte string.
I have tried using HSI16 ( 38400 baud ) and LSE ( 9600 baud ) but with no success for either.
I have tried LPUART wake on START and RXNE with no difference.
This is all with PROGRAM rather than DEBUG.
In DEBUG the program is successfully entering HAL_UARTEx_WakeupCallback where I am setting 'Comms_Timeout = 100' which is decremented in HAL_IncTick with a guard in PreSleepProcessing to not call HAL_SuspendTick or HAL_PWREx_EnterSTOP2Mode until Comms_Timeout reaches zero.
I have a GPIO toggle in HAL_UARTEx_WakeUpCallback and can see it on a scope when sending UART messages from a host in DEBUG, but not in PROGRAM where I am seeing the GPIO stuck low no matter how many messages I send to the MCU.
Flashing in DEBUG mode, running then disconnecting the debugger seems to work fine until I power cycle the MCU.
Any help or advice would be greatly appreciated.
2025-11-19 3:12 AM
Hello @CHemingway
Please make sure you call the following function as in the example LPUART_WakeUpFromStop:
HAL_UARTEx_StopModeWakeUpSourceConfig(&hlpuart1, WakeUpSelection)
2025-11-19 3:36 AM
void UART_DMA_Rx_Init ( void )
{
UART_WakeUpTypeDef wu = { .WakeUpEvent = UART_WAKEUP_ON_READDATA_NONEMPTY };
HAL_UARTEx_StopModeWakeUpSourceConfig(&hlpuart2, wu);Thanks @Saket_Om ,
This is already part of UART RX at startup
Is this the correct way to implement it and should it only be necessary the once at startup?
2025-11-19 6:16 AM
Hello @CHemingway
The best approach is to first ensure that LPUART wakeup functionality is working correctly using the example provided above. Once that is confirmed, you can proceed to integrate additional peripherals into the project
2025-11-19 7:13 AM
Is there an example of using LPUART and STOP mode with RTOS?
I will have multiple threads requiring low power control, or the prevention of, so I am intending to use tickless idle.
2025-11-19 7:49 AM
Hello @CHemingway
There is no example using LPUART and STOP mode with RTOS, but there is an example FreeRTOS_LowPower. Please check the link below: