Showing results for 
Search instead for 
Did you mean: 

STM32W55 - UART DMA only odd byte is received



I have a BLE application and I want to use UART DMA for communication between Nucleo and PC.

I have managed to get it working, however everytime only odd bytes are received. (One is received and the second one is not and again..) I'm attaching a screenshot from terminal. Here is my code, the communication is split by sending and receiving 1 byte, what I'm doing wrong? Can you please help me? Any suggestion would be appreciated! Thank you very much!

void Custom_APP_Init(void)


HAL_UART_Receive_DMA (&huart1, rx_message, 1);



void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)


HAL_UART_Receive_DMA(&huart1, rx_message, 1);

if(transmit == 0)


HAL_UART_Transmit_DMA(&huart1, rx_message, 1);

transmit = 1;




void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)





Karl Yamashita
Lead II

It's because your rx_message receives the next character before you can transmit the current character. So before you're able to transmit 'E', it gets overwritten by 'S', and so on.

To over come this, you need to buffer your received characters to a 2nd array. Then outside of your interrupt, you can transmit any available character(s) from that second array.

You can see this project to learn about ring buffers and how to receive strings of unknown size using idle bit.