2024-07-05 07:29 PM
Our product uses a STM32H7xx chip, integrate freeRTOS. We want our product can go into STOP mode to save power, and can be waked up from STOP by USART3 receiving data.
Below is some related code, but it does not work, our product can't be waked up by USART data.
MX_USART3_UART_Init is generated by CubeMx, we just add a few code at the beginning and end to config WUS clock and IT.
void MX_USART3_UART_Init(void)
{
/* USER CODE BEGIN USART3_Init 0 */
__HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_HSI);
/* USER CODE END USART3_Init 0 */
/* USER CODE BEGIN USART3_Init 1 */
/* USER CODE END USART3_Init 1 */
huart3.Instance = USART3;
huart3.Init.BaudRate = 115200;
huart3.Init.WordLength = UART_WORDLENGTH_8B;
huart3.Init.StopBits = UART_STOPBITS_1;
huart3.Init.Parity = UART_PARITY_NONE;
huart3.Init.Mode = UART_MODE_TX_RX;
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart3.Init.OverSampling = UART_OVERSAMPLING_16;
huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart3.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart3) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetTxFifoThreshold(&huart3, UART_TXFIFO_THRESHOLD_1_2) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_SetRxFifoThreshold(&huart3, UART_RXFIFO_THRESHOLD_1_2) != HAL_OK)
{
Error_Handler();
}
if (HAL_UARTEx_EnableFifoMode(&huart3) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART3_Init 2 */
__HAL_UART_ENABLE_IT(&huart3, UART_IT_RXNE);
__HAL_UART_ENABLE_IT(&huart3, UART_IT_WUF);
/* USER CODE END USART3_Init 2 */
}
Below is our code to go into STOP mode and wake up in one freeRTOS task.
HAL_SuspendTick();
HAL_UARTEx_EnableStopMode(&huart3);
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
HAL_ResumeTick();
SystemClock_Config();
2024-07-15 05:19 AM
Hello @HarryXia
There is an example in CubeH7 using UART wakeup from stop mode using FIFO:
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.