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.

RTOS/MSP432P401R: Using I2C to connect with MPU9250, but transfer function doesn't work

Part Number: MSP432P401R

Tool/software: TI-RTOS

Hello,

I am using the mpu for a project and the i2c transfer does not work. The i2c remains locked indefinitely since I use block mode, but with call back mode it does not make the transfer either. I think the mistake is that it doesn't recognize the slave device. The only thing I've checked is that the address is correct (0x68) for the MPU9250.

Any idea what might go wrong?

P.D.: the code:

I2C_Handle i2c;
I2C_Params params;
I2C_Transaction i2cTransaction;
uint8_t txBuffer[1];
uint8_t rxBuffer;
I2C_Handle ret;

I2C_Params_init(&params);
// params.transferMode = I2C_MODE_CALLBACK;
params.transferCallbackFxn = NULL;
params.bitRate = I2C_400kHz;
i2c = I2C_open(Board_I2C_TMP, &params);

txBuffer[0] = regAddr;

i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;

i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 1;

i2cTransaction.slaveAddress = 0x68;

ret = I2C_transfer(i2c, &i2cTransaction);

if (ret == NULL) {
System_printf("I2C did not tranfer\n");
}
else if (ret){
System_printf("I2C did the transfer\n");
}
System_flush();

I2C_close(i2c);

Thank you very much!!!

  • Have you been able to verify operation with one of the examples found in the resource explorer to confirm the hardware is working properly?
    dev.ti.com/.../


    Here is a link with some troubleshooting suggestions: www.ti.com/.../slaa734a.pdf .

    Regards,
    Chris
  • Hello again,

    Thank you for the link with the examples, it helps a lot. I found the problem in the MSP_EXP432 file, the pins are not well referenced. In the example use the following code to :

    const I2CMSP432_HWAttrsV1 i2cMSP432HWAttrs[MSP_EXP432P401R_I2CCOUNT] = {

    {
    .baseAddr = EUSCI_B1_BASE,
    .intNum = INT_EUSCIB1,
    .intPriority = (~0),
    .clockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK,
    .dataPin = I2CMSP432_P6_4_UCB1SDA,
    .clkPin = I2CMSP432_P6_5_UCB1SCL
    }};

    But in my code doesn't show the part of .dataPin and .clkPin, and it doesn't accepted it either.

    I try to define the pins in this part and then call the function init I2C in my main code:

    void MSP_EXP432P401R_initI2C(void)
    {
    /* Configure Pins 6.4 & 6.5 as SDA & SCL, respectively. */
    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6,
    GPIO_PIN4 | GPIO_PIN5, GPIO_PRIMARY_MODULE_FUNCTION);

    /* Initialize the I2C driver */
    I2C_init();
    }

    But, it doesn't work too.

    Any idea?

  • typedef struct I2CMSP432_HWAttrsV1 {
        /*! EUSCI_B_I2C peripheral's base address */
        uint32_t baseAddr;
        /*! EUSCI_B_I2C peripheral's interrupt number */
        uint32_t intNum;
        /*! EUSCI_B_I2C peripheral's interrupt priority */
        uint32_t intPriority;
        /*! EUSCI_B_I2C clock source */
        uint8_t  clockSource;
        /*! EUSCI_B_I2C clock pin configuration */
        uint16_t clkPin;
        /*! EUSCI_B_I2C data pin configuration */
        uint16_t dataPin;
    } I2CMSP432_HWAttrsV1;

    Are you using the most recent version of the SDK? 

    Regards,

    Chris

    Can you show the definition of the structure I2CMSP432_HWAttrsV1?  

    You should be able to find it in I2CMSP432.h

**Attention** This is a public forum