cancel
Showing results for 
Search instead for 
Did you mean: 

How to clear the DMA functions` redundancy words?

GShen.1
Associate II

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?

��

6 REPLIES 6

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
Associate II

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);

}

}

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
Associate II

like this:

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

Enter 10 Characters using Keyboard:

Hardware:STM32F0Discovery

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

JW

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.