This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LP-MSPM0G3507: DMA problem

Part Number: LP-MSPM0G3507


Hi TI,

I am using DMA for transport the I2C RXdata. When I tried to transport 1 byte at one time. It's success.

But if I send 2bytes or more at one time. It can only transmit the first data of each group.My code originally did not use DMA. But now I want to use DMA to transport data.

I found that in I2C IRQ , a set of data was originally looped through this switch statement, but DMA only triggered once, so only the first data was passed.

How can I solve this problem!!!

My config:

I really need your help!

  • Hi Junhao,

    Could you first refer to the example code with DMA?

    • uart_rx_multibyte_fifo_dma_interrupts
    • spi_controller_repeated_multibyte_fifo_dma_interrupts
    • ...
  • Hi Yuhao,

    Sorry for reply late.

    I just Modification the code,which is called "spi_controller_repeated_multibyte_fifo_dma_interrupts"

    Changed the SPI to I2C. Split 'SPI_send' into 'I2C_read' and 'I2c_write'.The remaining parts were also imitated.

    But it doesn't work.  The I2C interrupt can only switch in the red part case.

    And after that , the program just stuck in this

    So how should I transform the code! I really need help.

  • The reason why I want to use DMA is actually that I just want to use DMA for data transfer. That is to copy the data received by I2C, which can save CPU resources and the transmission process will not be interrupted. Then I found out that DMA accesses registers instead of FIFO when handling data. The data received by I2C is in FIFO, and the MRXDATA register only represents the initial value in FIFO. That is, if I use I2C to read and write multiple data at once, such as data of 4 bytes, So my DMA can only handle the first data 'A'. If I configure the DMA length to be 4, it will handle 'A' four times Because every time it is triggered, the MRXDATA register always contains the initial value of the FIFO, and if you want to refresh or delete the initial data of the FIFO, you need to use the CPU to read it. After reading this MRXDATA register using the CPU, the value inside will automatically refresh, but this goes against my original intention. My goal is to save CPU resources.

    Sorry for the madarin.

    我之所以想用DMA,其实我只是想用DMA做数据搬运。也就是拷贝I2C接收到的数据,这样就可以节省CPU资源并且传输过程不会被中断打断。然后我发现DMA搬运数据时是访问寄存器的而不是FIFO,I2C收到的数据在FIFO里,MRXDATA这个寄存器只表示FIFO里最开始的那个值。也就是如果我I2C一次性读写多个数据比如说4个bytes的数据,那么我DMA只能搬运第一个数据”A“,如果我配置DMA长度为4,那么他会搬运四次"A",因为它每次被触发的时候MRXDATA寄存器里一直都是FIFO最开始的值,而如果要刷新或者说删除FIFO最开始的数据,需要用CPU读取。用CPU读取这个MRXDATA寄存器后里面的值会自动刷新,但是这就违背了我的初衷。我的目的就是要节省CPU资源。

  • Hi Junhao,

    Thanks for your update. I'll check and reply to you soon.

  • Hi Yuhao,

    After several days I have some ideas.

    Now the problem is the DMA only triggers once per I2C communication. So I only get the last bytes.

    If I wanna get every single byte,  DMA should be triggerred after MRXFIFO recieved one byte.

    Maybe I should config this register:

    As a matter of fact, what I really want is an example. I have tried to transfer the SPI SDK to I2C, but failed!

    If there's any DMA I2C example , things will be much easier.

    Thank you so much.

  • Hi Junhao,

    I got your point.  Could you please tell me the email address? I will contact you later.

  • OK!

    junhao.shi@gc.omron.com

**Attention** This is a public forum