Skip to main content
GShen.1
Associate II
Jun 22, 2020 2:01 PM UTC
Question

How to clear the DMA functions` redundancy words?

when I use the DMA functions as below:

HAL_UART_Transmit_DMA(&huart1,(uint8_t *)aTxStartMessage,sizeof(aTxStartMessage));

HAL_Delay(10000);

In PC side,It always display such symbols at the hand of the aTxStartMessage after the first success reciever.

Which register should be set ?

What is the DMA function`s program process?

��

This topic has been closed for replies.

6 replies

Terry Greeniaus
Senior
Jun 22, 2020 4:57 PM UTC

How are you defining aTxStartMessage? Is it ASCII? Perhaps you are transferring the '\0' at the end of the C string if it is? You may wish to use the strlen() function instead of the sizeof() operator.

GShen.1
GShen.1Author
Associate II
Jun 23, 2020 4:36 AM UTC

In HAL_UART_Transmit_DMA function, *pdata should be defined to uint8_t.As below:

HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)

When I change the aTxStartMessage to char type, and the sizeof to strlen. That error still occur.

Main.c Program:

#include<string.h>

char aTxStartMessage[]="\r\n****UART-Hyperterminal communication based on IT****\r\nEnter 10 Characters using Keyboard:\r\n";

int main()

{

while(1)

{

HAL_UART_Transmit_DMA(&huart1,(uint8_t *)aTxStartMessage,strlen(aTxStartMessage));

HAL_Delay(10000);

}

}

waclawek.jan
Super User
Jun 23, 2020 6:38 AM UTC

And what exactly do you receive? Try a terminal program which can display binary (hex) values, such as Bray.

What hardware do you use to connect the STM32 to PC?

JW

GShen.1
GShen.1Author
Associate II
Jun 23, 2020 5:18 PM UTC

like this:

��****UART-Hyperterminal communication based on IT****

Enter 10 Characters using Keyboard:

Hardware:STM32F0Discovery

waclawek.jan
Super User
Jun 23, 2020 9:57 PM UTC

Insert a delay after initialization of the USART and before transmitting, with a duration of couple of characters.

JW

Terry Greeniaus
Senior
Jun 23, 2020 10:35 PM UTC

Oh, your weird characters are showing up at the start of the transmission, not at the end. I'm not sure which MCU you are using, but in RM0091 (STM32F0x1/F0x2/F0x8), under the "27.5.2 USART Transmitter" section, there is the following note:

"An idle frame will be sent after the TE bit is enabled."

I'm not sure if there's a way to disable that. I imagine this is what you are seeing in your terminal program. I think you are seeing the same thing as this thread:

https://community.st.com/s/question/0D50X00009XkaduSAB/how-to-stop-the-idle-frame-on-uart

and there were some suggestions there on how to deal with it.