HAL_I2C_Mem_Write_DMA issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-03 9:16 AM
Hi There,
I have searched a lot about the HAL_I2C_Mem_Write_DMA problem and seems like i have not found anywhere else this issue has been solved.
Can anyone contribute if someone has solved it.
Thanks
Solved! Go to Solution.
- Labels:
-
STM32F4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-04 4:55 AM - edited ‎2024-06-04 5:38 AM
Hi Andrew,
I found the solution from this link:-
I need to add below code and enable the I2c event interrupt. Seems working fine. But I need to tune my code a little bit more.
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c)
{
if (hi2c->Instance==hi2c1.Instance)
{
HAL_DMA_Abort_IT(hi2c->hdmatx);
}
}
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c)
{
if (hi2c->Instance==hi2c1.Instance)
{
HAL_DMA_Abort_IT(hi2c->hdmatx);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-03 9:25 AM
@Ganesh-K-Grg wrote:the HAL_I2C_Mem_Write_DMA problem
what problem?
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-04 1:47 AM - edited ‎2024-06-04 1:48 AM
Hi Evangelist,
Calling a write function to write about 6 bytes. But it keeps sending contineously a lot of data.
HAL_StatusTypeDef ret = HAL_I2C_Mem_Write_DMA(&hi2c1, (20 << 1) | 0, 4, 1, &to_reg[0], 6);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-04 2:34 AM
Does it work without DMA - ie, using HAL_I2C_Mem_Write ?
Please show a minimum but complete example which illustrates the problem.
What slave device are you using? Show your schematic of how it's connected.
Are you getting ACKs from the slave?
Please use this button to properly post source code:
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-04 3:25 AM - edited ‎2024-06-04 4:53 AM
Hi There,
Yes HAL_I2C_Mem_Write works for me.
I removed the I2C pins from the .ioc file and added back again without renaming the label name on SDA and SCL.
Now i can see that it can send exactly the 6 bytes. But looks like there is no NACK and SCL is pulling low. Iam connecting to RM3100 device.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-04 4:55 AM - edited ‎2024-06-04 5:38 AM
Hi Andrew,
I found the solution from this link:-
I need to add below code and enable the I2c event interrupt. Seems working fine. But I need to tune my code a little bit more.
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c)
{
if (hi2c->Instance==hi2c1.Instance)
{
HAL_DMA_Abort_IT(hi2c->hdmatx);
}
}
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c)
{
if (hi2c->Instance==hi2c1.Instance)
{
HAL_DMA_Abort_IT(hi2c->hdmatx);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-04 5:15 AM
@Ganesh-K-Grg wrote:I found the solution
Excellent - please mark your post as the solution.
https://community.st.com/t5/community-guidelines/help-others-to-solve-their-issues/ta-p/575256
A complex system designed from scratch never works and cannot be patched up to make it work.
