cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743I-Eval & I2C DMA

Marco Nehmelman
Associate II
Posted on April 02, 2018 at 22:07

Hi All,

Im trying to interface with a PCA9543A and a MT9P031 image sensor connected to I2C1 on my STM32H743I-eval board.

Using the

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-mcu-packages/stm32cubeh7.html

package I have managed to interface with both of the IC's on interrupt base (based on the I2C_TwoBoards_ComIT example).

Now I would like to use DMA for this task for which also an example is provided (I2C_EEPROM_fast_mode_plus) but I cant seem to get it to work.

On my I2cHandle I either receive error code 4 or 16 and the hdmatx returns error code 1 and in the example I2C_Error_Flag is set to 1. To configure the PCA9543 i only have to end 1 byte (0x01) to address 0xE6 but this already seems to fail with either HAL_I2C_Master_Transmit_DMA() or HAL_I2C_Mem_Write_DMA(). Im not sure why the example is failing.

After HAL_I2C_Master_Transmit_DMA() is called the code seems to be stuck in I2Cx_EV_IRQHandler(). When I check the SCL/SDA lines on a scope I do see the data and the clock but at the end of the message the SCL line stays low and is seems no STOP is generated.

Any help or other I2C DMA examples would be appreciated. I have attached my demo project code (true studio).

Thank you for your time!

1 REPLY 1
Marco Nehmelman
Associate II
Posted on April 03, 2018 at 21:10

Im now to the point where the HAL_I2C_Mem_Read() & HAL_I2C_Mem_Read_DMA() give the same waveform on the SCL/SDA lines on an oscilloscope but the HAL_I2C_Mem_Read_DMA() gives a HAL_DMA_ERROR_TE error which in turn generates HAL_I2C_ERROR_DMA but im not sure why?

    data[0]=0x02;

    data[1]=0x84;

    error = HAL_I2C_Mem_Write        (&hi2c1, 0xBA, 0x09, 1, data, 2, 100);     //Successful

    data[0]=0x00;

    data[1]=0x00;

    data[2]=0x00;

    memset(&data, 0, 3);

    error = HAL_I2C_Mem_Read        (&hi2c1, 0xBA, 0x09, 1, data, 2, 100);     //Successful

    memset(&data, 0, 3);

    error = HAL_I2C_Mem_Read_DMA    (&hi2c1, 0xBA, 0x09, 1, data, 2); // fails

    /* Wait for the end of the reception signaled using the callback HAL_I2C_MemRxCpltCallback*/

    while((I2C_Rx_Complete_Flag == 0) && (I2C_Error_Flag == 0))

    {

        /* wait untill I2C Reception ends or error */

    }

    /* Turn LED2 on: Transfer in reception process is correct */

    if(I2C_Rx_Complete_Flag != 0)

    {

        error++;

    }

    if(I2C_Error_Flag != 0)

    {

        error++;

    }