cancel
Showing results for 
Search instead for 
Did you mean: 

I2C & DMA how to configure correctly?

DK.7
Senior

I am a beginner and learning I2C DMA, could you tell me what I'm doing wrong?

I connected the LCD to Blue Pill and it works fine with function "HAL_I2C_Master_Transmit" i.e. without DMA!

But, when DMA is configured, it is dosn't works!

Very simple code, but I can not find a mistake!

Link to my main.c https://pastebin.com/cz7b2Bbu

0693W00000DnNeYQAV.png

1 ACCEPTED SOLUTION

Accepted Solutions
Imen.D
ST Employee

Hello @DK.7​ 

I advise you to start with the I2C example available under STM32CubeF1 MCU package, to use I2C via DMA:

\STM32Cube_FW_F1_V1.8.4\Projects\STM32F103RB-Nucleo\Examples\I2C\I2C_TwoBoards_ComDMA

Have a look at this FAQ "STM32 I2C does not work" describes few tips related to I2C peripheral on STM32 devices.

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

Imen

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

View solution in original post

4 REPLIES 4
TDK
Guru

You need to wait for the transfer to complete before starting another DMA transfer. You can do so by polling the state of the handle.

You should always monitor the return status from HAL_* to verify it succeeds (HAL_OK).

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

Hello @DK.7​ 

I advise you to start with the I2C example available under STM32CubeF1 MCU package, to use I2C via DMA:

\STM32Cube_FW_F1_V1.8.4\Projects\STM32F103RB-Nucleo\Examples\I2C\I2C_TwoBoards_ComDMA

Have a look at this FAQ "STM32 I2C does not work" describes few tips related to I2C peripheral on STM32 devices.

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

Imen

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

Thanks for answers! I rewrote my code according to the example, but something does not work! Link to my new main.c https://pastebin.com/BvDa3ivg

0693W00000DnQEnQAN.png

DK.7
Senior

I found my mistake, one more time THANK YOU!

my code now https://pastebin.com/yP56NqX8