cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 HAL UART transmission

kmehranh
Associate II
Posted on December 08, 2016 at 09:38

I'm trying to send data by STM32f103 to an Arduino board using UART. Data isn't received properly. The code is generated using STM32CUBEMX and here is the part I added:

uint8_t Test[] = '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 \n'; //Data to send HAL_UART_Transmit(&huart1,Test,sizeof(Test),1000);// Sending in normal mode HAL_Delay(1000); HAL_UART_Transmit_DMA(&huart1,Test,sizeof(Test));// Sending in DMA mode HAL_Delay(1000);

the received data is:

 {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1}

in both DMA and normal modes the received data is pretty similar. The UART baud rate is 115

What should I do?

#uart #dma-usart #stm32f1 #stm32cube
2 REPLIES 2
Amel NASRI
ST Employee
Posted on December 08, 2016 at 11:10

Hi

‌,

The issue seems to be within the amount of data to be sent provided as parameter in the call ofHAL_UART_Transmit_DMA orHAL_UART_Transmit.

In the examples available in the Cube package, a 'COUNTOF' macro is defined to precise the amount of data:

#define COUNTOF(__BUFFER__) (sizeof(__BUFFER__) / sizeof(*(__BUFFER__)))�?

Ex:STM32Cube_FW_F1_V1.4.0\Projects\STM32F103RB-Nucleo\Examples\UART\UART_TwoBoards_ComDMA

-Amel-

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.

Posted on December 09, 2016 at 07:15

Hello, thanks for your answer. 

The baud rate between STM32 and Arduino wasn't match!  I used lower baud rate and it's working fine.