Skip to main content
GLONG
Associate
June 15, 2019
Question

Problem: i2c with DMA

  • June 15, 2019
  • 2 replies
  • 1053 views

To exchange data with my display I am using the i2c protocol. I decided to exchange data with the DMA but I have problems. Without DMA everything works perfectly. Communication does not go well with Dma. The configuration is the default, and the only difference in the code is the name of the 'transmit' and 'receive' ending with DMA. What can the problem be due to? I'm going crazy

Configuration DMA

 /* I2C1_TX Init */
 
 hdma_i2c1_tx.Instance = DMA1_Stream6;
 
 hdma_i2c1_tx.Init.Channel = DMA_CHANNEL_1;
 
 hdma_i2c1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
 
 hdma_i2c1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
 
 hdma_i2c1_tx.Init.MemInc = DMA_MINC_ENABLE;
 
 hdma_i2c1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
 
 hdma_i2c1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
 
 hdma_i2c1_tx.Init.Mode = DMA_NORMAL;
 
 hdma_i2c1_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
 
 hdma_i2c1_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
 
 if (HAL_DMA_Init(&hdma_i2c1_tx) != HAL_OK)
 
 {
 
 Error_Handler();
 
 }

I attach the library I use to communicate with the display .. very simple

    This topic has been closed for replies.

    2 replies

    S.Ma
    Principal
    June 15, 2019

    Well mostly use SPI which bit rate calls for DMA the most.

    When using HAL DMA, make sure you get the proper I2C callback (don't use DMA callbacks directly).

    Was told : Read carefully HAL comments on top of H and C file.

    Or check out if there is a Nucleo I2C+DMA example to get started.

    GLONG
    GLONGAuthor
    Associate
    June 15, 2019

    I study from a book and I followed what he told me ... I don't understand where I'm wrong.