Skip to main content
Explorer II
May 23, 2023
Question

Communicating with I2C DMA Without Interrupt

  • May 23, 2023
  • 3 replies
  • 4896 views

Hi, 

I am trying to communicate with i2c DMA without interrupt. My MCU is STM32G474RET6.

I've read that it is possible but can't find how to do it. 

How can i communicate in slave mode with i2c dma?

Since my interrupts disabled, can't use the callback functions. I've checked the signal and after address, bus is hanged and not gave ACK.

    This topic has been closed for replies.

    3 replies

    ST Employee
    May 23, 2023

    Hello @Günce Yasan​ ,

    For I2C communication using DMA, you should configure DMA setting using STM32CubeMX by adding I2Cx_TX or I2Cx_RX as showing in the figure :


    _legacyfs_online_stmicro_images_0693W00000bkgNgQAI.png 

    Foued

    guncccAuthor
    Explorer II
    May 23, 2023

    Hi @KHALSI_Foued​ 

    Yes i did those configurations. Here's my cubemx conf.
    _legacyfs_online_stmicro_images_0693W00000bkgOAQAY.png
    _legacyfs_online_stmicro_images_0693W00000bkgOFQAY.png
    _legacyfs_online_stmicro_images_0693W00000bkgOZQAY.pngNormally when interrupt enabled, i use callback functions to do my receive/transmit proccess. Since i don't use interrupt, i see in my function I2C ADDR flag is set, and after that i try to receive with dma but my program goes into infinite loop. Is there some function i should call before receive func. or etc. ?

    ST Employee
    May 23, 2023

    Open main.c

    add :

    /* Receive in master mode an amount of data in non-blocking mode with DMA */
    HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,uint16_t Size)

    and try to put this function between user code begin 4 and user code end 4 to make sure that the transfer completed :

    /*Master Rx Transfer completed callback. */
     
    void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *I2cHandle)
    {
    /* ########### */
    }

     Foued

    ST Employee
    June 5, 2023

    Hi @Günce Yasan​ 

    The forum moderator had marked your post as needing a little more investigation and direct support. An online support case has been created on your behalf, please stand by for just a moment and you will hear from us.

    Regards,

    Billy

    Graduate II
    March 30, 2024

    hi @gunccc  

    have you got any solution for this problem?

    because im also facing same issue... when im calling HAL_I2C_Mem_Write_DMA function then salve is going into BUSY state and after that not comint out from BUSY state at all. but HAL_I2C_Mem_Write is working fine.