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: Opening different I2C buses on separate USCI ports in one project

Part Number: MSP432P401R
Other Parts Discussed in Thread: LDC1614

Tool/software: TI-RTOS

Hello,

I am working with MSP432P401R, CCS V6.2, currently on the PZ100 breakout socket, but moving to a custom board soon.  I am trying to interface with 4 separate LDC1614 inductive sensors, 2 per I2C bus (only have high/low address selection on each chip).  I can successfully talk to the chip on different I2C lines, but can't figure out how to map different pins for an I2C_open() command.

I started from the i2ctmp006 I2C w/ RTOS example.  I can start I2C and change the pins.  

I have changed the pin mapping in MSP_EXP432P401R.c in MSP_EXP432P401R_initI2C(void) to map to pins on USCI_B2

/* Configure Pins 3.6 & 3.7 as SDA & SCL, respectively. */
MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P3,
GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);

And I see how I can change/add I2C names here

typedef enum MSP_EXP432P401R_I2CName {
//MSP_EXP432P401R_I2CB0 = 0,

MSP_EXP432P401R_I2CB0,

MSP_EXP432P401R_I2CCOUNT
} MSP_EXP432P401R_I2CName;

This name is defined in board.h, and I can change that.  I am having trouble figuring out how the i2c_open() index will map to the correct USCI bus so I can open a separate I2C bus.  Or do I need to set up a new set of I2C params, rather than the default ones.  

Thanks for the help, let me know if you need more info/context!

  • Jackson,

    Can I ask why you are using CCS v6.2? This should be much easier with CCS7.1 using the SimpleLink MSP432 SDK and the I2C TI Driver. See the example below which has two threads running I2C master/slave off of USCIB0 and B1.
    e2e.ti.com/.../2165083

    Architecturally, since the above example is using TI RTOS, this should map well to how you should set up multi-bus I2C with your device.
    In this case, you have two seperate .c files that have the thread functions and each thread function has a call to I2C_Open(I2CBUSNAME, &i2cParams);

    The typdef enum in the MSP_EXP432P401R.h that i have is the following:

    typedef enum MSP_EXP432P401R_I2CName {
        MSP_EXP432P401R_I2CB0 = 0,
        MSP_EXP432P401R_I2CB1,
    
        MSP_EXP432P401R_I2CCOUNT
    } MSP_EXP432P401R_I2CName;

  • Thank you Evan,

    Migrating to 7.1 did solve the problem, as the pins are explicitly connected to the I2C_Name in MSP_EXP432P401R.c in 

    const I2CMSP432_HWAttrsV1 i2cMSP432HWAttrs[MSP_EXP432P401R_I2CCOUNT] = {
        {
            .baseAddr = EUSCI_B0_BASE,
            .intNum = INT_EUSCIB0,
            .intPriority = (~0),
            .clockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK,
            .dataPin = I2CMSP432_P1_6_UCB0SDA,
            .clkPin = I2CMSP432_P1_7_UCB0SCL
        },
        {
            .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
        },
        {
    	.baseAddr = EUSCI_B2_BASE,
    	.intNum = INT_EUSCIB2,
    	.intPriority = (~0),
    	.clockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK,
    	.dataPin = I2CMSP432_P3_6_UCB2SDA,
    	.clkPin = I2CMSP432_P3_7_UCB2SCL
    	},
        {
    	.baseAddr = EUSCI_B3_BASE,
    	.intNum = INT_EUSCIB3,
    	.intPriority = (~0),
    	.clockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK,
    	.dataPin = I2CMSP432_P6_6_UCB3SDA,
    	.clkPin = I2CMSP432_P6_7_UCB3SCL
        }
    };

    I went ahead and set up all the I2C buses just to test them out.  I also needed to add a declaration for each in 

    const I2C_Config I2C_config[MSP_EXP432P401R_I2CCOUNT]

    as well as add the identifiers in the I2C_Name function from above.

    This seems to be working for now, thanks for the help!

**Attention** This is a public forum