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/MSP430F5659: I2C port initialization for I2CUSCIB1 and I2CUSCIB2

Part Number: MSP430F5659

Tool/software: TI-RTOS

Hi,

I am working TI RTOS based application for MSP430F5659 controller, I have 2 I2C bus in my design

i.e. 

I2CUSCIB1 - for EEPROM/Temp IC

I2CUSCIB2 - for serial to parallel switch IC

i am using below code to initialize the I2C handle ,

I2CUSCIB_Object i2cUSCIBObjects[MSP_MSP430F5659_I2CCOUNT];

const I2CUSCIB_HWAttrs i2cUSCIBHWAttrs[MSP_MSP430F5659_I2CCOUNT] = {

{

.baseAddr = USCI_B1_BASE,

.clockSource = USCI_B_I2C_CLOCKSOURCE_SMCLK

},

 {

   .baseAddr = USCI_B2_BASE,

     .clockSource = USCI_B_I2C_CLOCKSOURCE_SMCLK

}

};

const I2C_Config I2C_config[] = {

{

.fxnTablePtr = &I2CUSCIB_fxnTable,

.object = &i2cUSCIBObjects[0],

.hwAttrs = &i2cUSCIBHWAttrs[0]

},

 {

  .fxnTablePtr = &I2CUSCIB_fxnTable,

  .object = &i2cUSCIBObjects[1],

  .hwAttrs = &i2cUSCIBHWAttrs[1]

 }

};

/*

* ======== MSP_MSP430F5659_initI2C ========

*/

void MSP_MSP430F5659_initI2C(void)

{

/*

* NOTE: TI-RTOS examples configure USCIB0 as either SPI or I2C. Thus,

* a conflict occurs when the I2C & SPI drivers are used simultaneously in

* an application. Modify the pin mux settings in this file and resolve the

* conflict before running your the application.

*/

GPIO_setAsPeripheralModuleFunctionInputPin( GPIO_PORT_P8,

GPIO_PIN5 | GPIO_PIN6);

 GPIO_setAsPeripheralModuleFunctionInputPin( GPIO_PORT_P9,

 GPIO_PIN5 | GPIO_PIN6);

 

I2C_init();

}

Is this correct way to handle the 2 I2C buses?

i want to know whether this will create any issue, while handling application.

Please guide me if any other way of handling the I2C routines.

Earlier i had single bus I2CUSCIB1 with multiplexed and is it working fine, Now i am adding one more bus I2CUSCIB2 .

Thanks in advance

Nitesh

I2CUSCIB_Object i2cUSCIBObjects[MSP_MSP430F5659_I2CCOUNT];

//#ifdef EEPROM

const I2CUSCIB_HWAttrs i2cUSCIBHWAttrs[MSP_MSP430F5659_I2CCOUNT] = {

{

.baseAddr = USCI_B1_BASE,

.clockSource = USCI_B_I2C_CLOCKSOURCE_SMCLK

},

// {

// .baseAddr = USCI_B2_BASE,

// .clockSource = USCI_B_I2C_CLOCKSOURCE_SMCLK

// }

};

const I2C_Config I2C_config[] = {

{

.fxnTablePtr = &I2CUSCIB_fxnTable,

.object = &i2cUSCIBObjects[0],

.hwAttrs = &i2cUSCIBHWAttrs[0]

},

// {

// .fxnTablePtr = &I2CUSCIB_fxnTable,

// .object = &i2cUSCIBObjects[1],

// .hwAttrs = &i2cUSCIBHWAttrs[1]

// }

};

/*

* ======== MSP_MSP430F5659_initI2C ========

*/

void MSP_MSP430F5659_initI2C(void)

{

/*

* NOTE: TI-RTOS examples configure USCIB0 as either SPI or I2C. Thus,

* a conflict occurs when the I2C & SPI drivers are used simultaneously in

* an application. Modify the pin mux settings in this file and resolve the

* conflict before running your the application.

*/

GPIO_setAsPeripheralModuleFunctionInputPin( GPIO_PORT_P8,

GPIO_PIN5 | GPIO_PIN6);

//

// GPIO_setAsPeripheralModuleFunctionInputPin( GPIO_PORT_P9,

// GPIO_PIN5 | GPIO_PIN6);

 

I2C_init();

}

  • Hi Nitesh,

    That looks basically correct to me, although I haven't checked whether or not the pin numbers are correct.  You need to also edit the board's header file to add the second I2C to the enum.  For example:

    typedef enum MSP_EXP430F5529LP_I2CName {
        MSP_EXP430F5529LP_I2CB0 = 0,

        MSP_EXP4305529LP_I2CB1 = 1,

        MSP_EXP430F5529LP_I2CCOUNT
    } MSP_EXP430F5529LP_I2CName;

    Best regards,

    Janet

  • Thanks Janet,

    Even i have a question whether we need to update the .cfg file for adding interrupt for second I2C bus handling?

    Please comment, Thanks in advance

    Nitesh

  • Hi Nitesh,

    Yes, you would need to add another Hwi to the .cfg file.  You can use the same ISR function.  I'm not sure of the interrupt number, but the .cfg code may look something like this:

    hwiParams.arg = 1;
    halHwi.create(45, "&I2CUSCIB_hwiIntFxn", hwiParams);

    Best regards,

    Janet

  • Thanks,

    i have added the new interrupt in .cfg and testing, i will come back if any issue.

    Thanks for the support,

    Nitesh