2021-10-14 01:13 PM
I was trying to read the 24AA64FT EEPROM using the I2C DMA methods. But the I2C read will break after reading 2 bytes for no reason, and both SDA and SCL stay low. As you can see in the picture, the reading starts with writing 0x50 (0xA0 >> 1) to the EEPROM, then it reads 0x30 and 0x78 and it just stops.
Here is the code, my I2C was configured with STM32CubeMX, I enabled the RX DMA and event/error interrupt.
uint8_t pBuff[64];
memset(pBuff, 0, sizeof(pBuff));
uint8_t res;
// HAL_I2C_Mem_Read works fine
// res = HAL_I2C_Mem_Read(&hi2c1, 0xA0, 0, I2C_MEMADD_SIZE_16BIT, pBuff, 64, 100);
// HAL_I2C_Mem_Read_DMA will stop after reading 2 bytes
res = HAL_I2C_Mem_Read_DMA(&hi2c1, 0xA0, 0, I2C_MEMADD_SIZE_16BIT, pBuff, 64);
Here is the result for HAL_I2C_Mem_Read, there is no problem.
Solved! Go to Solution.
2021-10-15 02:43 AM
Maybe consequence of CubeMX incorrectly ordering initialization of DMA https://community.st.com/s/question/0D50X0000Bmob3uSQA/dma-not-working-in-cubemx-generated-code-order-of-initialization ?
JW
2021-10-15 02:43 AM
Maybe consequence of CubeMX incorrectly ordering initialization of DMA https://community.st.com/s/question/0D50X0000Bmob3uSQA/dma-not-working-in-cubemx-generated-code-order-of-initialization ?
JW
2021-10-15 07:23 AM
Thank you! It is the CubeMX init order problem.
2021-10-15 07:28 AM
I solved the problem by place the DMA init before I2C init.
MX_GPIO_Init();
MX_DMA_Init();
MX_I2C1_Init();
I'm using the STM32CubeMX 6.3.0 Linux version. Hope this problem will be fixed in the future.
2021-10-15 08:21 AM
Hello @GChen.5 ,
This problem will be fixed in the next release of CubeMx.
Thanks for your contribution.
Imen