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.

MSPM0C1104: MSPM0C1104 I2C controller can not read register data

Part Number: MSPM0C1104

Tool/software:

I develop a SW code on a MSPM0C1104 EVB.

Now, we need to read the register contents from the slave I2C device.

The spec. of this I2C device reading timing is 

 Reading flow of this device is: 

I2C_START, Slave_Addr+W, Reg_Addr, 

I2C_START, Slave_Addr+R, Data1, Data2, Data3, Data4, I2C_STOP.

I use and modify from the sample code "C:\ti\mspm0_sdk_2_03_00_07\examples\nortos\LP_MSPM0C1104\driverlib\i2c_controller_rw_multibyte_fifo_poll".

 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "ti_msp_dl_config.h"
/*
* Number of bytes to send from Controller to target.
* This example uses FIFO with polling, and the maximum FIFO size is 4.
* Refer to interrupt examples to handle larger packets
*/
#define I2C_TX_PACKET_SIZE (3)
/*
* Number of bytes to received from target.
* This example uses FIFO with polling, and the maximum FIFO size is 4.
* Refer to interrupt examples to handle larger packets
*/
#define I2C_RX_PACKET_SIZE (3)
/* Data sent to the Target */
uint8_t gTxPacket[I2C_TX_PACKET_SIZE] = {0x00, 0x61, 0x00};
/* Read Register Address*/
uint8_t gRegisterAddr[2] = {0x10, 0x14};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

In ths main function, I add this read fucntion before the final while loop.

Unfortunately, the program is halt in I2C read because the SCK kept low

Could anyone has soltuion for this problem. Thanks

  • I think this should be 2 not 1. Can you try again?

  • Hi, Eason

       As your sugggestion, the number was modified to 2 

            DL_I2C_fillControllerTXFIFO(I2C_0_INST, &regAddr[0], 2);
    It is the same, 
    Thanks for your reply.
  • Can you change this to be enable and also change the value from 1 to 2.

  • >while (DL_I2C_getControllerStatus(I2C_INST) &
    >   DL_I2C_CONTROLLER_STATUS_BUSY_BUS)

    BUSBSY will be set until the STOP, so it won't clear here. Try instead:

    >while (DL_I2C_getControllerStatus(I2C_INST) &
    >  DL_I2C_CONTROLLER_STATUS_BUSY)

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

    Or better yet: Use the RD_ON_TXEMPTY feature. Don't do the initial (TX) half-transaction, but instead call:

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

    then do the RX part of the transaction. The I2C unit will write the bytes in the Tx FIFO, then perform the Rx transaction.