Communicating with I2C DMA Without Interrupt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-23 5:47 AM
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.
- Labels:
-
DMA
-
I2C
-
Interrupt
-
STM32G4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-23 7:02 AM - edited ‎2023-11-20 4:47 AM
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 :
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-23 7:07 AM - edited ‎2023-11-20 4:48 AM
Hi @KHALSI_Foued​
Yes i did those configurations. Here's my cubemx conf. Normally 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. ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-23 7:13 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-23 10:43 PM - edited ‎2023-11-20 4:48 AM
I am working in slave mode so i used slave configurations. Here is my code.
The LED is toggling. But it doesn't goes into the callback.
I see from my ISR reg the address is matched. But after that can't take the command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-06-05 11:17 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-30 2:12 AM
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.
