2024-06-03 09: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.
2024-06-04 04:55 AM - edited 2024-06-04 05: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);
}
}
2024-06-03 09:25 AM
@Ganesh-K-Grg wrote:the HAL_I2C_Mem_Write_DMA problem
what problem?
2024-06-04 01:47 AM - edited 2024-06-04 01: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);
2024-06-04 02: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:
2024-06-04 03:25 AM - edited 2024-06-04 04: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.
2024-06-04 04:55 AM - edited 2024-06-04 05: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);
}
}
2024-06-04 05: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