cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between HAL_I2C_Master_Transmit_IT and HAL_I2C_Master_Transmit_DMA

MAmem.1
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Foued_KH
ST Employee

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.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
Foued_KH
ST Employee

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.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.