2025-01-31 11:54 AM - edited 2025-01-31 11:56 AM
Hi there,
I am trying to set up UART3 to receive and transmit using Interrupt.
My setup is simple to verify the issue. These are the steps that I did:
1. Add Uart3 in .ioc file with the configuration as:
2. In main(), before entering while(1) loop, I start receive_IT as:
HAL_UART_Receive_IT(&huart3, bufTemp, 1);
3. Add Callback function as:
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
HAL_UART_Receive_IT(huart, bufTemp, 1);
}
The problem that I am running into that is if I send "1234\r\n", my HAL_UART_RxCpltCallback() only triggers twice, and I can see "1" and "2" in my buffer.
I also verified ErrorCode before HAL_UART_Receive_IT() is called in the callback function. It turned out the error was an Overrun Error.
Could someone please give me some suggestions on how to solve this issue?
Sincerely,
Solved! Go to Solution.
2025-01-31 12:51 PM
Please ignore this post. The issue was with my code, and setting up the breakpoint did not capture one character at a breakpoint trigger, which caused the confusion.
2025-01-31 12:51 PM
Please ignore this post. The issue was with my code, and setting up the breakpoint did not capture one character at a breakpoint trigger, which caused the confusion.
2025-01-31 01:54 PM
Keep in mind that reading DR while debugging can have side effects. It clears the RXNE flag.
Also note that while paused, the peripheral is still working and will overflow if characters come in without being read/handled.
2025-01-31 02:01 PM
I was not aware of that initially. Thank you for the advice.