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-MSPM0L2228: I2C stop condition enable/disable

Part Number: LP-MSPM0L2228

Tool/software:

Hello,

I'm trying to communicate to a target using I2C bus, but there is something odd I need to clarify.

How to read a byte from the target device using I2C: send start, send device address (write), receive ack, send register address, receive ack, send repeated start, send device address (read), receive ack, receive byte, send nack, send stop.

From a driverlib point of view, I'm trying to set up this transaction using DL_I2C_startControllerTransferAdvanced(I2C_ACCELEROMETER_INST,writeAddress,DL_I2C_CONTROLLER_DIRECTION_TX,0x01,DL_I2C_CONTROLLER_START_ENABLE,DL_I2C_CONTROLLER_STOP_DISABLE,DL_I2C_CONTROLLER_ACK_ENABLE), but I got no reply. Analyzing the bus I found that a stop condition is sent anyway:

I followed the i2c polled example provided in MSPM0 SDK 2.02.00.05.

Target device is NXP's FXLS8964AF (on this evaluation board).

  • You're getting a NACK, so the I2C unit automatically terminates the transaction. According to FXLS8964AF datasheet (rev 3.4) Sec 12.1, its I2C address is 0x18 (or 0x19 if SA0=1).

    Unsolicited: In most cases, such a piecewise transaction can be done (with fewer headaches) using the RD_ON_TXEMPTY feature. [Ref TRM (SLAU847D) Sec 21.2.4.1.3]

    Briefly:

    1) Enable the feature:

    DL_I2C_resetControllerTransfer(I2C_INST);  // Set MCTR=0 to avoid enableControllerReadOnTXEmpty hazard
    DL_I2C_enableControllerReadOnTXEmpty(I2C_INST); // Write then read

    2) Write the register address to the Tx FIFO

    3) Perform the Rx transaction with DL_I2C_startControllerTransfer() [don't count the Tx FIFO contents in the length]

    4) Disable the feature [I'm not sure this is needed, but it seems proper]

    [Same as above but using DL_I2C_disableControllerReadOnTXEmpty()]

    DL_I2C_resetControllerTransfer(I2C_INST);  // Set MCTR=0 to avoid disableControllerReadOnTXEmpty hazard
    DL_I2C_disableControllerReadOnTXEmpty(I2C_INST); // Turn off Repeated Start feature

    [Edit: Insert code for (4) since E2E didn't allow that before(?)]

  • Hi Daniele,
    Bruce's solution should help you fix this stop condition. I also recommend downloading and installing the latest version of the SDK.
    Best Regards,
    Diego Abad

  • Hello Bruce,
    I misunderstood the API so I passed the 8 bit address with R/W flag already set.

    The functionality suggested works fine, I've just added a wait cycle between the DL_I2C_startControllerTransfer call and the subsequent DL_I2C_receiveControllerData call, otherwise I miss the byte read.

    Thank you very much for your support!!