cancel
Showing results for 
Search instead for 
Did you mean: 

Communicating with I2C DMA Without Interrupt

gunccc
Associate II

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.

6 REPLIES 6
Foued_KH
ST Employee

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

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.

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. ?

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

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.

I am working in slave mode so i used slave configurations. Here is my code.


_legacyfs_online_stmicro_images_0693W00000bkjZLQAY.pngThe LED is toggling. But it doesn't goes into the callback.


_legacyfs_online_stmicro_images_0693W00000bkjZfQAI.pngI see from my ISR reg the address is matched. But after that can't take the command.


_legacyfs_online_stmicro_images_0693W00000bkja9QAA.png

Billy OWEN
ST Employee

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

JJhin.1
Senior II

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.