2024-10-31 08:31 AM - last edited on 2024-10-31 08:35 AM by Andrew Neil
The attached code configures UART communication to wake up a microcontroller in sleep mode as soon as a frame is received. In sleep mode, the micro waits for data on the UART interface, and when a UART frame is detected, it automatically wakes up to process the received information. Each byte is then processed immediately, allowing for a quick response to incoming data.
However, with my two STM32 Nucleo L031K6 development boards, I have noticed different results during the tests of sending and receiving frames via RealTerm. Indeed, the behavior of the microcontroller becomes inconsistent when the frame sent from RealTerm exceeds three bytes.
What could be the causes of the inconsistency in the behavior of the STM32 Nucleo L031K6 microcontroller when receiving frames that exceed three bytes, and what solutions could be considered to address this issue?
2024-10-31 08:48 AM
Hello @messaoudi,
Try increasing the UART receive buffer, it's may be caused by buffer overflow
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.
2024-11-04 01:17 AM - last edited on 2024-11-04 01:29 AM by Andrew Neil
2024-11-04 01:32 AM
Since reception is handled byte by byte, you need to ensure that the processing of each byte is completed before the next one arrives!
Are you sure your code achieves that?
Does it work without STOP ?
How about using a ring-buffer to "catch" receive characters - so that you can then process them "at leisure" ... ?
2024-11-07 04:23 AM
I disabled the STOP mode and wake-up via UART, which allowed for correct operation.
Here are the commented-out lines of code:
// __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_HSI);
// __HAL_RCC_USART2_CONFIG(RCC_USART2CLKSOURCE_HSI);
// WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_READDATA_NONEMPTY;
// if (HAL_UARTEx_StopModeWakeUpSourceConfig(&UartHandle, WakeUpSelection)!= HAL_OK)
// {
// Error_Handler();
// }
// HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);