cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_I2C_Master_Receive_DMA not returning updated values.

AKuma.33
Associate II

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.

4 REPLIES 4
TDK
Guru

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

Hi TDk,

Thanks for your reply.

I am not using ADC, but I2C.

Imen.D
ST Employee

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

Do you call MX_DMA_Init before MX_I2C_Init?

If you feel a post has answered your question, please click "Accept as Solution".