Skip to main content
AKuma.33
Associate II
October 29, 2021
Question

HAL_I2C_Master_Receive_DMA not returning updated values.

  • October 29, 2021
  • 4 replies
  • 1746 views

Hi,

I am using one I2C based peripherals with Interrupt enabled.

While using "HAL_I2C_Master_Transmit" and "HAL_I2C_Master_Receive", it seems to work properly with ISR.

But, when I am using the following I2C_DMA:

HAL_I2C_Master_Receive_DMA(&hi2c4, MPU_DEVICE_ADDR, mpu_datapair, 14);

It doesn't return updated values, it reads once and stops after that.

CubeIDE configuration includes:

  • I2C4 in fast mode with DMA enabled with the Memory address incrementation
  • ISR enabled for Sensor Interrupt

Controller:

  • NUCLEO-L4P5ZG

ISR for reference here:

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
 UNUSED(GPIO_Pin);
 if (GPIO_Pin == GPIO_PIN_12)
 {
	 HAL_I2C_Master_Receive_DMA(&hi2c4, MPU_DEVICE_ADDR, mpu_datapair, 14);
 }
}

I have also tried "HAL_I2C_Master_Transmit_DMA" for transmitting address, but no luck so far.

Any help would be much apreciated.

This topic has been closed for replies.

4 replies

TDK
October 29, 2021

Do you call MX_DMA_Init before MX_ADC_Init?

"If you feel a post has answered your question, please click ""Accept as Solution""."
AKuma.33
AKuma.33Author
Associate II
November 1, 2021

Hi TDk,

Thanks for your reply.

I am not using ADC, but I2C.

TDK
November 1, 2021

Do you call MX_DMA_Init before MX_I2C_Init?

"If you feel a post has answered your question, please click ""Accept as Solution""."
ST Technical Moderator
November 1, 2021

Hi @Community member​ ,

@TDK​ means that maybe you have the DMA initialization issue (using CubeMx v6.3.0) which needs to be before any other peripheral initialization.

So, in this case try update the line MX_DMA_Init(); before any other peripheral initialization.

I'll be waiting for your feedback.

When your issue is solved, please close this topic by choosing Select as Best. This will help other users find that answer faster.

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