Skip to main content
Visitor II
April 18, 2022
Solved

Difference between HAL_I2C_Master_Transmit_IT and HAL_I2C_Master_Transmit_DMA

  • April 18, 2022
  • 1 reply
  • 1323 views

Hi,

I know that DMA can save CPU time by transfering data from memory to peripheral (and from peripheral to memory) but it not clear how this works for I2C since the I2Cx_EV_HANDLER is still called when I changeI2C from IT configuration to DMA configuration.

I need to write/read from (STM32G474VET6) I2C without CPU intervention.

    This topic has been closed for replies.
    Best answer by Foued_KH

    Hello @MAmem.1​ ,

    DMA requests are generated by Data Register becoming empty in transmission and Data Register becoming full in reception.

    The CPU can be seen as if it’s suppressed, and to unleash its full working power this data transfer task has to be handed over to another unit and here it comes the DMA unit to offload these exhausting data transactions from the CPU.

    0693W00000VOp7FQAT.png(Example of STM32F103C8T6 architecture)

    As you can see in the diagram above, the existence of the DMA unit can now direct the data stream coming from the I2C peripheral directly to the memory while the CPU doing other stuff and calculations. This parallel cooperation between the CPU and the DMA is where the acceleration stems from.

    Hope my answer helped you!

    When your question is answered, please close this topic by choosing Select as Best.

    This will help other users find that answer faster.

    Foued.

    1 reply

    Foued_KHAnswer
    ST Employee
    November 3, 2022

    Hello @MAmem.1​ ,

    DMA requests are generated by Data Register becoming empty in transmission and Data Register becoming full in reception.

    The CPU can be seen as if it’s suppressed, and to unleash its full working power this data transfer task has to be handed over to another unit and here it comes the DMA unit to offload these exhausting data transactions from the CPU.

    0693W00000VOp7FQAT.png(Example of STM32F103C8T6 architecture)

    As you can see in the diagram above, the existence of the DMA unit can now direct the data stream coming from the I2C peripheral directly to the memory while the CPU doing other stuff and calculations. This parallel cooperation between the CPU and the DMA is where the acceleration stems from.

    Hope my answer helped you!

    When your question is answered, please close this topic by choosing Select as Best.

    This will help other users find that answer faster.

    Foued.