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.

MSPM0G3507: Can you please provide the steps to configure DMA for I2C send in controller mode.

Part Number: MSPM0G3507
Other Parts Discussed in Thread: SYSCONFIG

Q : When we write data to send on this certain DMA register, this should trigger the interrupt of I2C and start the communication.

It would be nice if you could share the step-by-step instructions to configure the same(registers)

  • Hi Lavina,

    I'd recommend that you do this starting with our i2c_controller_rw_multibyte_fifo_interrupts example, found in the SDK under: mspm0_sdk_1_30_00_03\examples\nortos\LP_MSPM0G3507\driverlib\i2c_controller_rw_multibyte_fifo_interrupts

    When you've imported this project, you can open the .syscfg file, open the I2C tab, then scroll down to the DMA configuration tab. You can configure a DMA channel to be triggered by the I2C TX FIFO here. Once you've configured the DMA channel in Sysconfig, you'll need to configure the source and destination addresses for the DMA using the DL_DMA_setSrcAddr() and DL_DMA_setDestAddr() functions. Once this is complete, and you have made sure to set the DMA transfer size (which can be done using DL_DMA_setTransferSize() or Sysconfig), you can enable the start of transfers with DL_DMA_enableChannel().

    To switch this example to use DMA, you'll also want to get rid of the DL_I2C_fillControllerTXFIFO() function that the example uses. Since we do not have a published I2C with DMA example, I'd also recommend that you use the SPI with DMA example to help with development, which is found in the SDK here: mspm0_sdk_1_30_00_03\examples\nortos\LP_MSPM0G3507\driverlib\spi_controller_fifo_dma_interrupts

  • I've done the configuration in my project as below by referring to the example.

                /*! DMA channel config*/
                DMA_ConfigureChannelData(   DMA_Channel0, SIZE_8_BIT, &txdatabuffer, &I2C1->MASTER.MTXDATA1);

                /*! Select I2C event publisher as DMA channel0 trigger*/
                DMA_TriggerSelection(DMA_Channel0, DMA_I2C1_TX_TRIG);

                DMA_SetSingleTransfer(DMA_Channel0);
                DMA_EnableChannel(DMA_Channel0);

    As soon the channel is enabled, I'm expecting the I2C TXDATA register to be filled, which is not happening. Is there any additional configuration to be done?
  • Have you also enabled the I2C DMA in Sysconfig? Could you post an image of the tab showing its configuration settings?

    Looking at the functions above, these are not driverlib functions. I could not tell you whether this properly initializes the DMA as I do not know what these functions do. 

    The general process should be:

    initialize trasnfer mode, destination and source address increment, destination and source data width, trigger, and trigger type.

    Then, set source address, destination address, transfer size, then enable the schannel.

  • If the only one-byte data is to be transferred, is it required to do destination and source address increment?

  • If you are transferring data from one unchanging singular address to another unchanging singular address, you do not need to increment either address.

    I think what may be helpful is to take a look at the MSPM0 DMA Academy first, then try designing the example.

  • Could you please share the steps to configure DMA channel to send 5 bytes of data to I2C peripheral

  • Edit the example shown in the MSPM0 DMA academy to send 5 bytes. Then edit the example so that the destination register is the I2C TX buffer. The base addresses are 0x400F0000 for I2C0 and 0x400F2000 for I2C1. The offset for both of these is 0x1220. So the TX buffer is located at 0x400F1220 for I2C0 and 0x400F3220 for I2C1. Make sure that the I2C is initialized before the DMA transmission. For information on how to initialize the I2C, see the example in the MSPM0 I2C Academy.

  • Up to 8bytes of data the TXFIFO is able to handle via DMA. More than 8bytes the I2C stop byte is not getting enabled.

    Is there any byte count limitation for the TXFIF0? Like in single transfer mode only upto 8bytes can be put to the FIFO at a time?

  • when I transfer more the 8bytes of data via I2C the stop bit doesn't get enabled, it there any limitation in the number of bytes that can be send out at a time from the Tx FIFO

  • Hi Lavina,

    The I2C FIFOs are 8 bytes deep. So if you transfer more than 8 bytes into the I2C FIFO at a time, it will fill up and your data won't send correctly. Viewing the I2C DMA configuration tab in Sysconfig, you can see there are trigger settings for when the FIFO is partially full. If you use these settings and single transfer mode, the FIFO won't be overwhelmed and the I2C transfer can be continuous.