Skip to main content
embvis
Associate III
January 24, 2017
Question

stm32f767 and UART DMA IT (interrupts)

  • January 24, 2017
  • 5 replies
  • 1848 views
Posted on January 24, 2017 at 11:07

Hi,

How to use UART in DMA mode with interrupts IT.

I use the next code to transmit, and it works perfect. 

HAL_DMA_Start_IT(&hdma_usart3_tx, (uint32_t)msg, (uint32_t)&huart3.Instance->TDR, strlen(msg));

huart3.Instance->CR3 |= USART_CR3_DMAT; // DMAT: DMA enable transmitter

But receive Rx doesnt work

:(

HAL_DMA_Start_IT(&hdma_usart3_rx, (uint32_t)&huart3.Instance->RDR, (uint32_t)uRxBuff, 8);

huart3.Instance->CR3 |= USART_CR3_DMAR; // DMA enable receiver

DMA config:

/* Peripheral DMA init*/

hdma_usart3_rx.Instance = DMA1_Stream1;

hdma_usart3_rx.Init.Channel = DMA_CHANNEL_4;

hdma_usart3_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;

hdma_usart3_rx.Init.PeriphInc = DMA_PINC_DISABLE;

hdma_usart3_rx.Init.MemInc = DMA_MINC_ENABLE;

hdma_usart3_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;

hdma_usart3_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;

hdma_usart3_rx.Init.Mode = DMA_NORMAL;

hdma_usart3_rx.Init.Priority = DMA_PRIORITY_LOW;

hdma_usart3_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;

hdma_usart3_rx.XferCpltCallback = &DMAReceiveComplete;

if (HAL_DMA_Init(&hdma_usart3_rx) != HAL_OK)

{

Error_Handler();

}

__HAL_LINKDMA(huart,hdmarx,hdma_usart3_rx);

hdma_usart3_tx.Instance = DMA1_Stream3;

hdma_usart3_tx.Init.Channel = DMA_CHANNEL_4;

hdma_usart3_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;

hdma_usart3_tx.Init.PeriphInc = DMA_PINC_DISABLE;

hdma_usart3_tx.Init.MemInc = DMA_MINC_ENABLE;

hdma_usart3_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;

hdma_usart3_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;

hdma_usart3_tx.Init.Mode = DMA_NORMAL;

hdma_usart3_tx.Init.Priority = DMA_PRIORITY_LOW;

hdma_usart3_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;

hdma_usart3_tx.XferCpltCallback = &DMATransferComplete;

if (HAL_DMA_Init(&hdma_usart3_tx) != HAL_OK)

{

Error_Handler();

}

__HAL_LINKDMA(huart,hdmatx,hdma_usart3_tx);

#stm32f7 #hal_uart_transmit_dma #interrupt #dma #stm32f767
This topic has been closed for replies.

5 replies

Oliver Beirne
Associate II
January 24, 2017
Posted on January 24, 2017 at 11:14

Hello

I have moved your post to the

https://community.st.com/community/stm32-community/stm32-forum?sr=search&searchId=0445f8b7-528c-419e-8c3d-1fe561f8525f&searchIndex=0

‌ where someone should be able to assist you.

Thanks

Oli

ST Technical Moderator
January 25, 2017
Posted on January 25, 2017 at 11:52

Hello

Zarzycki.Mikolaj.002

,

I suggest that you run and test the UARTexample withinthe last version of STM32CubeF7 firmware package relevant to the STM32 device you are using. This will help you on UARTconfiguration and identify

the root cause of reception error.

You may review the UART example using DMA under this path: STM32Cube_FW_F7_V1.6.0\Projects\STM32F769I_EVAL\Examples\UART

Regards

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
embvis
embvisAuthor
Associate III
January 25, 2017
Posted on January 25, 2017 at 11:58

Hi,

But there is no information how to use IT (interrupt) mode of DMA. I have problem with it, no with other modes

:(

I want use 

HAL_DMA_Start_IT, not HAL_UART_Receive_DMA or  HAL_UART_Transmit_DMA.

Thank you

Regards

Mikołaj

ST Technical Moderator
January 26, 2017
Posted on January 26, 2017 at 10:43

Hi Mikolaj Z,

Refer to the

http://www.st.com/content/ccc/resource/technical/document/user_manual/45/27/9c/32/76/57/48/b9/DM00189702.pdf/files/DM00189702.pdf/jcr:content/translations/en.DM00189702.pdf

 'Description of STM32F7xx HAL drivers', this will help you with more information about using DMA on 

interrupt mode.

Regards

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks