Skip to main content
kevin xu
Associate II
January 12, 2020
Question

Hi Guys I am using the DMA with uart and get some problem.

  • January 12, 2020
  • 2 replies
  • 1257 views

i using the cubmx and generate the code.

I add the code in main function below ,(sur_dma_data[100] is arry and uint16_t size send i defined them before). but it is dose not work. can not see the any data from serilas port of my board . i check data with computer serials tools and also does not stop the brakerpoint at call back function. the DMA setings in cubmx are ok,

i set the breakpoint in call back function as below.

//*****within Mina()

 HAL_UART_Transmit_DMA(&huart1,sur_dma_data,size_send);

//********

if i write this code  HAL_UART_Transmit_IT(&huart1,Pdata,1); to replace above DMA. anything is ok - I can see data at serials tools and also the call back function is called.

// -------call backe function

 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)

 {

//pro_counter++;

led_data=receive_data[0];

 

 }

//------------

any one can help me to settle the probelem ? thank you very much.

This topic has been closed for replies.

2 replies

KnarfB
Super User
January 12, 2020

Did you add the USART1_TX DMA channel in STM32CubeMX Configuration > USART1 > DMA Settings?

kevin xu
kevin xuAuthor
Associate II
January 13, 2020

HI KnarfB

thank you for your help.

all the setings and configruations are ok, and these set by Cubmx. I find out the problem ready. the problem is the executed squence of the DMA _int and uart1_int. it should be DMA_int firstly then uart1_int, otherwise it is does not work with DMA.

it work

MX_DMA_Init();

MX_USART1_UART_Init();

it does not work

MX_USART1_UART_Init();

MX_DMA_Init();

waclawek.jan
Super User
January 13, 2020

Read out and check the relevant DMA and USART registers content.

JW

kevin xu
kevin xuAuthor
Associate II
January 13, 2020

Hi Waclawek

thank you for your help.

all the setings and configruations are ok, and these set by Cubmx. I find out the problem ready. the problem is the executed squence of the DMA _int and uart1_int. it should be DMA_int firstly then uart1_int, otherwise it is does not work with DMA.

it work

MX_DMA_Init();

MX_USART1_UART_Init();

it does not work

MX_USART1_UART_Init();

MX_DMA_Init();

Amel NASRI
Technical Moderator
January 23, 2020

Is your code initially generated with latest STM32CubeMX version (5.5)?

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.