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.

MSPM0L1305: How to send I2C Target Address

Part Number: MSPM0L1305
Other Parts Discussed in Thread: MSPM0L1306

How to send I2C target address

1) To send target address do we need to write in MTXDATA register (Tx Buffer)?

Or

2) If we write target address in MSA[SADDR] it will send automatically after setting MCTR[START] bit?

In second case how controller knows target address is transmitted successfully? As there is no interrupt for address.

Need information on this. 

  • Hi, 

    Please refer to demo code from SDK:

    C:\ti\mspm0_sdk_2_00_00_03\examples\nortos\LP_MSPM0L1306\driverlib\i2c_controller_rw_multibyte_fifo_poll

    Here is the target address:

    /* I2C Target address */
    #define I2C_TARGET_ADDRESS (0x48)

    Used here:

    DL_I2C_startControllerTransfer(I2C_INST, I2C_TARGET_ADDRESS,
    DL_I2C_CONTROLLER_DIRECTION_TX, I2C_TX_PACKET_SIZE);

    Written to:

    i2c->MASTER.MSA[10:1]

    1) To send target address do we need to write in MTXDATA register (Tx Buffer)?

    Write I2C FIFO first. and then start transfer.

    If we write target address in MSA[SADDR] it will send automatically after setting MCTR[START] bit?

    Yes. It is recommended to refer to API function [DL_I2C_startControllerTransfer] to configure the I2C startup code.

    /**
     *  @brief      Sets up a transfer from I2C controller
     *
     *  Set target address, transfer direction, burst length, START+STOP generation.
     *  @note   Reading/writing data must be done separately.
     *
     *  @param[in]  i2c         Pointer to the register overlay for the peripheral
     *  @param[in]  targetAddr  Target address [0x00, 0x3FF]
     *  @param[in]  direction   One of @ref DL_I2C_CONTROLLER_DIRECTION
     *  @param[in]  length      Intended burst length in number of bytes
     */
    __STATIC_INLINE void DL_I2C_startControllerTransfer(I2C_Regs *i2c,
        uint32_t targetAddr, DL_I2C_CONTROLLER_DIRECTION direction,
        uint16_t length)
    {
        // Specify target address and read/write mode
        DL_Common_updateReg(&i2c->MASTER.MSA,
            ((targetAddr << I2C_MSA_SADDR_OFS) | (uint32_t) direction),
            (I2C_MSA_SADDR_MASK | I2C_MSA_DIR_MASK));
    
        // STOP bit is generated after burst length number of bytes transferred
        DL_Common_updateReg(&i2c->MASTER.MCTR,
            (((uint32_t) length << I2C_MCTR_MBLEN_OFS) | I2C_MCTR_BURSTRUN_ENABLE |
                I2C_MCTR_START_ENABLE | I2C_MCTR_STOP_ENABLE),
            (I2C_MCTR_MBLEN_MASK | I2C_MCTR_BURSTRUN_MASK | I2C_MCTR_START_MASK |
                I2C_MCTR_STOP_MASK));
    }

    ------------------------------------

    Please refer to demo code from SDK:

    C:\ti\mspm0_sdk_2_00_00_03\examples\nortos\LP_MSPM0L1306\driverlib\i2c_controller_rw_multibyte_fifo_poll

    Regards,

    Helic