Showing results for 
Search instead for 
Did you mean: 

Is there a guide on how to use I2C with DMA?

Associate III


I've been able to use I2C to communicate with I/O extender and display drivers with HAL. I'm now trying to use the I2C with HAL using DMA.

The problem is that UM1785 Description of STM32F0 HAL and low-layer drivers is a bit vague on explanations. STM32 offers examples, but that's not really what I'm looking for, and videos, but I'd rather have a written article (with a written article I can read at my own speed, easily skip or re-read parts, copy text, and so on).

Are their learning tools such as UMs or Application notes dedicated to the subject?



There are examples you can follow along with. Reasonably documented in code comments and the readme.

If you feel a post has answered your question, please click "Accept as Solution".
ST Employee

Hello @Matth​ and welcome to the Community 🙂

You will find a working I2C_TwoBoards_ ComDMA examples (relevant to the device that you are using) provided with STM32CubeF0 MCU package

The list of examples provided in the table 2, on the AN4735 Application note STM32Cube firmware examples for STM32F0 Series;

Have a look also at this FAQ: STM32 I2C does not work, which describes general tips related to I2C on STM32 devices.

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.



When your question is answered, please close this topic by clicking "Accept as Solution".

Thanks for the answer.

However, I'm afraid learning directly from an example would be an exercise in cargo cult programming, where one wanting to learn will have to copy/paste the whole project and snip bit by bit what seems to be specific to the example (communication between two boards) to keep the parts relevant to the subject (I2C with DMA).

I'd rather have an article focussed on a subject, in this case I2C with DMA.

First part gives a synthetic view of the processes, such as what the article provides.

Then the MCU configuration could be addressed, with explanations of the different setting possibilities (with pros and cons). In such a case, how to add DMA settings to I2C configuration, etc.

Then a synthetic description of the main.c code what is in main(), what is in the infinite loop. Also a part on how settings can be changed on the fly if needed (peripherals with different speeds or addressing?) and of course the proper I2C transmitting and receiving functions.

It can be helpful for programmers who are not yet familiar with MCU.

Such an article would give away to make things work, to understand how it works, and where to look for for if on wants to make the process more efficient.

Andrew Neil
Evangelist III

Looking for the same thing just now, I came across this old thread.

I know @Matth1 didn't want videos, but these two do seem to cover how to set up a comms peripheral with DMA:

STM32CubeMX basics: 10.11 STM32Cube HAL labs UART - UART DMA:

STM32CubeMX basics: 11.3 STM32Cube HAL labs SPI - Lab SPI DMA:


There doesn't seem to be one specifically for I2C, but the process should be the same?