2025-04-10 12:48 AM - last edited on 2025-04-10 1:17 AM by Andrew Neil
Hello every one .
this is my first post so excuse me if i do something wrong.
I try to establish Uart Asynchronous line between two stm32f303k8 .one of them use basic timer to send 8 byte uint buffer every 200 mili-sec and the other use HAL_UART_Receive_IT first in the "/* USER CODE BEGIN 2 */"
and circularly recall it again in HAL_UART_RxCpltCallback.
So my problem is that after the first reception i get overrun error and when i enable overrun in the CubeMX i see that after the first reception the first byte are the last byte of the previous message and all other bytes are shifted right .
**I attached image of my UART configuration (same for both of them)
Sender variables :
uint8_t m_tx_buffer[8] = {0};
uint8_t flag = 0;
Sender while(1):
if (flag == 1)
{
flag = 0;
HAL_UART_Transmit_IT(&huart1, m_tx_buffer, sizeof(m_tx_buffer));
m_tx_buffer[5] ++;
}
Receiver variables :
volatile uint8_t s_rx_buffer[8] = {0};
uint8_t s_tx_buffer[8] = {0};
uint8_t flag = 0;
Receiver Callback :
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
while(HAL_UART_GetState(huart) == HAL_UART_STATE_BUSY);
memset(s_rx_buffer, 0, sizeof(s_rx_buffer));
HAL_UART_Receive_IT(huart, s_rx_buffer, sizeof(s_rx_buffer));
}
I basically try everything, and it is not working. I try to move to DMA and i try to change the word length of the Uart I try to use slowing the sending of messages and try to see other's post on the internet. and i really not understanding how to fix that.
Source code formatting applied
Solved! Go to Solution.
2025-04-10 3:53 AM
@unsigned_char_array wrote:
I wrote about this before:
Indeed - it is a very commonly recurring theme!
2025-04-13 12:45 PM
thanks a lot i decide to change the Uart-rx to circular mode and the Tx remain in normal mode and it is fix the problem!!
2025-04-14 1:42 AM
Excellent - so please mark the solution:
https://community.st.com/t5/community-guidelines/help-others-to-solve-their-issues/ta-p/575256