2022-01-17 05:52 AM
Hello
Having real issues with the I2C DMA HAL code ???
Is it buggy.... very likely from what i'm reading on the web or is there something I am not understanding ??
I'm simply trying to read data back from a i2c flow sensor with minimal interruption to the processor thus why trying to use HAL I2C DMA
when I use use NON DMA I2C code everything is great and works well
HAL_I2C_Master_Receive( &hi2c1, Sensor_Adr << 1 | 0x01, I2C1_DATA , 9, HAL_MAX_DELAY );
Yet when I use the HAL I2C DMA code its broken ????
HAL_I2C_Master_Receive_DMA( &hi2c1, Sensor_Adr << 1 | 0x01 , I2C1_DATA, 9);
this should work the same way the non DMA code work, but using the DMA hardware, but we can see it does not....
we can see it starts to initiate a DMA I2C session, but stops after dropping SDA & SCL line why ??????
It should continue to read back the data from the sensor the same way the Non DMA I2C code does. ??
Can someone please help and advise as I am totally lost, what am I missing or is there a bug, thank you in advance for any help
I found this on the internet, not sure if its relevant
I had been struggling with the same problem on STM32F407 and I2C1.
After searching for potential bugs in the program flow, i found out that the function HAL_I2C_Master_Transmit_DMA leads to following line:
dmaxferstatus = HAL_DMA_Start_IT(hi2c->hdmatx, (uint32_t)hi2c->pBuffPtr, (uint32_t)&hi2c->Instance->DR, hi2c->XferSize);
After the first transfer, this won't return HAL_OK, which is necessary for the transmission to continue.
So my solution was simply abort the previous DMA interrupt in the callback function which is called after the transmission has completed. The same can be implied with HAL_I2C_Master_Receive_DMA. To resolve the problem, i added the following callback functions in main.c:
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c)
{if (hi2c->Instance==hi2c1.Instance)
{HAL_DMA_Abort_IT(hi2c->hdmatx);
}
}
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c)
{if (hi2c->Instance==hi2c1.Instance)
{ HAL_DMA_Abort_IT(hi2c->hdmarx);
}
}
I have tried adding these interrupt call backs but still does not work ??
can someone please advise a workaround for this bug or let me know what I am doing wrong
thank you for any help
regards
2022-01-18 07:47 AM
> There has to be a better way to develop and get support
There is, and it involves money exchanging hands.
2022-01-18 08:06 AM
@JHERI Well, it has already been pointed out that the community is primarily a user driven forum, occasionally there are ST colleagues here.
If you like to get personal, direct support, feel free to log into st.com/ols and open a ticket. Please keep in mind that the support there works worldwide and has to prioritize the projects according to importance.
Otherwise, @MM..1 and @TDK have already made good suggestions, above all, the repository is an extremely good help both in learning basic functions, and very usable as a copy template. Consider here however that the project in the Repository use relative paths, thus within the Repository refer. So it will not work to simply copy a project from the repository without resolving these references.
For learning purposes, you can instead create a copy (e.g. PROJECT_BAK) of a project of interest in the same directory level, compile the actual project with your IDE, and then use the copy later to compare what has changed.
Good luck!
Regards
/Peter
2024-02-17 06:22 AM
I am going through the exact same problem. any solution to this yet?
2024-02-17 06:56 AM
I have it working by:
1) Ensuring the I2C event interrupt is enabled in addition to the DMA interrupt (the former wasn't)
2) By adding HAL_DMA_Abort_IT(hi2c->hdmarx); into the callback as suggested by JHERI
2024-03-08 09:43 PM - edited 2024-03-08 09:47 PM
blox fruit mod menu auto farm mobile apk is a modified version of the game tailored for mobile devices. It features a mod menu allowing players to access various cheats and enhancements, including auto farming capabilities. However, downloading and using such APKs may violate the game's terms of service and expose users to security risks. Caution should be exercised when interacting with unofficial or modded versions of games.
2024-11-11 02:16 AM
//don't forget to activate I2C3 Event/Error Interrupt