Showing results for 
Search instead for 
Did you mean: 

Please consider writing an article on how to configure I2C with DMA with MX

Associate III

I've asked a question about using I2C with DMA.

I've had answers, but these were mostly advices to use an example. As I explained, in short: "learning directly from an example would be an exercise in cargo cult programming".

MX is a very useful tool to configure the µCU for beginners. (that is people who know programming but are not familiar with µCU, or are used to work on Arduino) but still require some knowledge.

I think an article that would offer

  • an abstract overview of the process (that is, in this example, I2C using DMA),
  • then a walkthrough the configuration (with explanations of the different setting possibilities, their with pros and cons, ...),
  • and a description of functions
  • and examples

would help users learn rather than copy code from an example and hope for the best.

It's also an opportunity for users to have a preview of surrounding topics they can dive deeper into if they want to.

In my case, using HAL drivers to use I2C in blocking mode was possible with a little googling and trial and error. Switching to DMA is tricky since most example codes or HAL drivers descriptions (such as UM 1785) don't address configuration with MX. Linking I2C with DMA, in addition to interrupts. is less intuitive than with I2C in blocking mode.


You could post it to the idea zone.

Dont see how using examples to learn is cargo cult.

If you feel a post has answered your question, please click "Accept as Solution".
Associate III
  1. The Idea part feature is about products, not support or learning tools; you'll see that in the topic list to choose from. This list doesn't include learning tool/documentation.
  2. Copying code from an example to try to make it work is cargo-cult programming by definition, to me.

I would like to have a simple api which does a full I2C master translation from start to stop, restart included betweeb the writes and read. Then, depending on the baud rate and data payload, a dma could be used if its handle is passed, otherwise ram emulated dma would be chosen. One API for most useage. In bare metal, anything that blocks less than around 10msec could be contemplated.