Skip to main content
Visitor II
December 2, 2024
Solved

DMA execution request order, I2C.

  • December 2, 2024
  • 1 reply
  • 894 views

Hi,

I'm using Nucleo board with Stm32CubeIde and HAL library.

I have a periodic interrupt every 10 ms and I want to acquire data from 8 sensors with I2C bus each with a different address.

At the interrupt output I must already have all the data to copy into a circular buffer. For I2c requests I want to use DMA.

So I start eight requests at the same time, what I want to know is if the callback DMA interrupt is called in the same order as the request to have the correct data.

If not, how can I solve this problem?

Thank you in advance

Domenico

    This topic has been closed for replies.
    Best answer by domenicocelentano

    I dis some tests and these are results of the discussion.

    1 - Request to the DMA are not buffered so it is not possible to make more than one request before the first one is finished.

    2 - If I have to wait in the periodic interrupt for the end of the transfer, it makes no sense to use DMA when there are only a few bytes to receive. DMA setups take longer than just requesting. Even use the interrupt is overkill. The simplest solution is to use the blocking function.

    Thank you all for your help in understanding the problem.

    Domenico

     

    1 reply

    Super User
    December 2, 2024

    Is it 8 devices on the same I2C bus? Then you cannot do this:

    > So I start eight requests at the same time

    You start one I2C process, whatever it takes, and when it finishes, you have to start the next one. That requires software intervention, usually the DMA triggers an interrupt when its transfer is done.

    JW

     

    Visitor II
    December 3, 2024

    Thanks for your reply.

    Yes, these devices are on the same I2C bus with different address.

    So you mean that it is possible to initiate eight DMA requests because they are buffered, but it is not guaranteed that the DMA callbacks , which is called eight times correctly, happen in the same order as the request?

    Is this correct?

    Domenico

     

     

     

    Graduate
    December 3, 2024

    You are interacting with a single physical interface, using a single DMA channel (or not using it - not really useful for I2C). What you really need is a software state machine implemented mostly in I2C MemRead callback routine, doing a scan of your sensors.