Skip to main content
Visitor II
August 8, 2024
Question

Failed to use I2C DMA for STM32F072

  • August 8, 2024
  • 1 reply
  • 791 views

Issue description as below:

1. STM32F072+STM32CUBEMX+FREERTOS+I2C1 DMA

2. I2C1 was set for rx DMA 

supgz_0-1723110535016.png

supgz_1-1723110557778.png

2. I use HAL_I2C_Mem_Read_DMA() for external device memory reading and it retured HAL_OK,but no data written to DMA buffer , DMA1_Channel2_3_IRQHandler for i2c1 DMA was not entered

3. Then I tried HAL_I2C_Mem_Read() and it read data successfully

4. I have tried HAL_I2C_Mem_Read_DMA() for STM32F105 and data can be read successfully.

 

My question:

1. why i2c dma read faied to get data from i2c slave for stm32f072?

2. what else should be done for stm32f072 i2c dma read?

3. any difference of i2c usage between stm32f072 and stm32f105?

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    August 9, 2024

    Hello @supgz ,

    Make sure to enable I2C1 with the right pin & configuration (e.g., PB6 for I2C1_SCL and PB7 for I2C1_SDA).

    Enable DMA for both I2C1_RX and I2C1_TX. Enable FreeRTOS with the necessary settings (heap size, task priorities). Ensure that the interrupt handlers for I2C and DMA are properly set up.

    Check I2C, clock Speed.

    You can follow the I2C examples within STM32F072 device:

    In order to make the program work, you must follow the instructions in the readme file.

    Have a look at this article which describes general tips related to I2C on STM32 devices:

    supgzAuthor
    Visitor II
    August 12, 2024

    Hi Imen:

       Thanks for your reply.

     

        1. i2c can read successfully when not using DMA, so i2c hw and sw configuration is OK on stm32f072

        2. i2c dma read also successfully on STM32F105, I can't get the difference of i2c dma usage between stm32f072 and stm32f105