cancel
Showing results for 
Search instead for 
Did you mean: 

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

Matth1
Associate III

Bonjour,

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?

M.R.

4 REPLIES 4
TDK
Guru

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

https://github.com/STMicroelectronics/STM32CubeF0/blob/4390ff6bfb693104cf97192f98c3dc9e3a7c296a/Projects/STM32F072B-Discovery/Examples/I2C/I2C_TwoBoards_ComDMA/Src/main.c

If you feel a post has answered your question, please click "Accept as Solution".
Imen.D
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.

Imen

Imen

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

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 https://community.st.com/s/article/stm32-i2c-does-not-work 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: 

https://www.youtube.com/watch?v=BxFYmBYBmaU

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

https://www.youtube.com/watch?v=s9GCTLd6-AM&list=PLnMKNibPkDnGtuIl5v0CvC81Am7SKpj02&index=52

 

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