2025-05-16 2:03 AM - last edited on 2025-05-16 2:11 AM by Andrew Neil
Hello folks,when I was using the HAL library function to implement MCU wake-up service from STOP2 mode through LPUART serial port, I found that no matter how the data was sent, the MCU could not exit STOP2 mode. Below are the relevant configurations configured by my cubemx,the MCU I am using is STM32WLE5CCU6.
Related MAIN Codes:
UART_WakeUpTypeDef WakeUpSelection={0};
void sss(){
printf("[INFO]Enter Stop!\n");
HAL_Delay(10); //??
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);
while (__HAL_UART_GET_FLAG(&hlpuart1, USART_ISR_REACK) == RESET);
__HAL_UART_ENABLE_IT(&huart1,UART_IT_WUF);
HAL_UARTEx_EnableStopMode(&huart1);
HAL_Delay(10);
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,PWR_SLEEPENTRY_WFE);
}
void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart) {
SystemClock_Config();
HAL_ResumeTick();
MX_GPIO_Init();
MX_LPUART1_UART_Init();
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_3,GPIO_PIN_SET);
}
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
MX_LPUART1_UART_Init();
MX_RTC_Init();
/* USER CODE BEGIN 2 */
// Get_Flash();
HAL_UARTEx_ReceiveToIdle_IT(&hlpuart1,uart_buff,sizeof(uart_buff));
HAL_UARTEx_ReceiveToIdle_IT(&huart1,uart_buff2,sizeof(uart_buff2));
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_3,GPIO_PIN_RESET);
HAL_Delay(2000);sss();
HAL_UARTEx_DisableStopMode(&hlpuart1);
HAL_UARTEx_ReceiveToIdle_IT(&hlpuart1,uart_buff,sizeof(uart_buff));
printf("LORA START!\r\n");
while (1){}
These are some problems I have encountered, and I hope the experts can propose some solutions,thank you.
Edited to apply source code formatting - please see How to insert source code for future reference.
2025-05-16 2:40 AM
Hello @BAIFAN
Could you please try to refer to the LPUART_WakeUpFromStop2_Init example (don't forget to read carefully the readme file). This should guide you on how to implement the wake-up throw LPUART from STOP2 mode. You can then migrate the same process on your MCU.
Best Regards.
STTwo-32
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.
2025-05-16 2:46 AM
I just referred to the official routine and took a small section of the code for the first wake-up, but my test results showed no response. The wake-up callback function HAL-UARTEx-Wakeupcallbacks seems to have not entered.
2025-05-16 2:52 AM
Could you please try to review if the message is well transmitted to the LPUART from the source (maybe you should review it throw the oscilloscope). If it works fine, you can follow the example I've recommended and try to implement your config based on the config on this project.
Best Regards.
STTwo-32
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.