cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_I2C_Mem_Write_DMA() doesn't work no matter what on my H7, HAL_I2C_Mem_Write_IT() works.

HTD
Senior III

The board is STM32H747I-DISCO.

I have configured I2C chip (PCA9555) properly, it works in interrupt mode.

I configured BDMA for TX and RX, default options.

I also have DCache disabled because I know it causes problems on H7.

First, there are bugs in HAL starting on initializing I2C4. The generated code is buggy, it generates a conflicting internal function name, does not compile.

I fixed it by renaming the offending function in discovery_bus.c.

Then more bugs jumps in when I enable register callbacks for I2C. Mixed names again, but again, I fixed it and it works in interrupt mode. Registered callbacks are called properly.

Then I switched my calls to use DMA. For that only BDMA is selectable in STM32CubeIDE. I have my channels configured, interrupts enabled.

I run my code and first - HAL_I2C_Mem_Write_DMA() returns HAL_OK, but then my callback is never called. Also - touch screen stops working.

I suspected initialization order. The STMCubeIDE's code generator loves to initialize the peripherals that use DMA before DMA initialization. For UART - this causes exactly described behavior. The function returns HAL_OK but the callback is never called. After changing the initialization order - DMA (not BDMA) works for UARTs properly. I mean - the order that works for me: MX_DMA_Init(), MX_UARTx_Init().

However, I tested both orders with I2C4 and BDMA and neither works.

I'm out of ideas for how to make it work and I just changed my calls to HAL_I2C_Mem_Write_IT(). But I'm curious - what's the catch here?

What are probable reasons for BDMA not working on H7? Maybe the touchscreen driver is using the I2C in a way that can work with BDMA? I'm not yet on the level to investigate that myself right now.

0 REPLIES 0