Skip to main content
Frogram
Associate II
August 27, 2021
Question

use both I2C Master DMA and UART DMA at once

  • August 27, 2021
  • 2 replies
  • 2009 views

Hi all,

I am trying to use I2C DMA as Master and UART DMA

My code is

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
 if (c == 1) {
	 HAL_UART_Transmit_DMA(&huart2, (uint8_t *)b, 8);
 } else {
	 /* I2C Transmit code */
 }
 c = 1 - c;
}

and which I tried are (instead of /* I2C Transmit code */) :

// 1. polling, it worked
	 HAL_I2C_Master_Transmit(~~, 50);
	 HAL_I2C_Master_Receive(~~, 50);
// 2. DMA, not worked
 HAL_I2C_Master_Transmit_DMA(~~);
 HAL_I2C_Master_Receive_DMA(~~);
// 3. Mem read dma, not worked
	 HAL_I2C_Mem_Read_DMA(~~);
// 4. Seq DMA, not worked
	 HAL_I2C_Master_Seq_Transmit_DMA(~~, I2C_FIRST_FRAME);
	 HAL_I2C_Master_Seq_Receive_DMA(~~, I2C_LAST_FRAME);

I have no Idea whats wrong and how to solve it

thanks

This topic has been closed for replies.

2 replies

Amel NASRI
Technical Moderator
August 30, 2021

Hi @Frogram​ ,

  1. Does Uart DMA work properly?
  2. Is your initialization code generated with STM32CubeMX? If you are using latest STM32CubeMX version 6.3.0, please make sure to have correct order for HAL_DMA_Init() and peripheral init.

-Amel

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.
Frogram
FrogramAuthor
Associate II
August 30, 2021

Hi

  1. yes, UART DMA works well
  2. I used STM32CubeIDE for create .ioc and here is no HAL_DMA_Init() only MX_DMA_Init(). how could I add it?
Amel NASRI
Technical Moderator
August 30, 2021

Yes it is MX_DMA_Init().

Please make sure that it is called after MX_I2C_Init().

-Amel

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.
Frogram
FrogramAuthor
Associate II
August 30, 2021

The code was already set as you said. TT