Skip to main content
kmehranh
Associate II
December 8, 2016
Question

STM32 HAL UART transmission

  • December 8, 2016
  • 2 replies
  • 1164 views
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
This topic has been closed for replies.

2 replies

Amel NASRI
ST Technical Moderator
December 8, 2016
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 "Best Answer" on the reply which solved your issue or answered your question.
kmehranh
kmehranhAuthor
Associate II
December 9, 2016
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.