cancel
Showing results for 
Search instead for 
Did you mean: 

Why I could not receive the data properly in the UART ??

Vel
Associate III

Hi Team,

I am using stm32h753 controller, While receiveing data in the UART. Rx buffer index is not always Rxbuff[0]. Data is received randomly in the different index.

Here i am attaching the reference.

0690X00000AQto3QAD.png

1 ACCEPTED SOLUTION

Accepted Solutions
Vel
Associate III

Hi Clive,

Please find the code..

buffer size in 250 .

I am receiving 16 byte data.

0690X00000AQueEQAT.png

View solution in original post

7 REPLIES 7
Tilen MAJERLE
ST Employee

Can you post the code how you receive data? It is unclear from your print screen.

Hi, Tilen MAJERLE,

Please find the code...

0690X00000AQuLRQA1.png

Can't you just paste more complete code?

How large is the buffer?

You ignore error status from the function.

You ignore the fact data reception may be of different sizes, or shift in alignment/synchronization.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Vel
Associate III

Hi Clive,

Please find the code..

buffer size in 250 .

I am receiving 16 byte data.

0690X00000AQueEQAT.png

HAL_UART_Receive length parameter accepts number of bytes to receive. You put size of buffer, put 16 instead and function will terminate after it receives 16 bytes.

Vel
Associate III

Hi Tilen,

If i want to change the buffer size, each time i don't want to change it manually. How it can be done with out giving specific value to it.

One Note:-

The given code passing array buffer index was mentioned.

HAL_UART_Receive(&huart2, (uint8_t *)rxdata[0], sizeof(rxdata), 1000);

correct one:-

HAL_UART_Receive(&huart2, (uint8_t *)rxdata, sizeof(rxdata), 1000);

Vel
Associate III

Hi Tilen,

As of now , i am try to change the receive buffer size equal to transmit buffer size(16 byte). Till i am facing the same issue. I am using USART in Asynchronism mode.