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.

MSP432E401Y: Set I2C bit rate to specific value.

Part Number: MSP432E401Y
Other Parts Discussed in Thread: MSP-EXP432E401Y,

Hello, 

I am using the MSP432E401Y (currently via the MSP-EXP432E401Y LaunchPad).  I am branching my code off of the existing example "i2ctmp007_MSP_EXXP432401Y_nortos_ccs" only with different booster packs.  In I2C.h I see the default options for the I2C bit rate as 100 kbps, 400 kbps, 1 Mbps, and 3.33 Mbps. However, I need to use a value different from these 4 options (≈2.94 MHz).  Is there a way that I can send a different value to i2cParams.bitRate?  

I got this code example from the Resource Explorer in CCS, and for some reason do not seem to have access to I2C.c to edit the bit rate manually.  

  • Mitch,
    You'll basically have to reconfigure the clock after the I2C_Open() on your own to do this. The i2cParams.bitRate parameter is just an enumerated type rather than some number reflecting the actual frequency, so no other values of bitRate parm will work here.
    Things to note:
    1. Your i2c frequency is high enough that you'll need to ensure that you are running the cpu at 120MHz.
    2. I would start by configuring the I2C as if you are using the 3.33Mbps mode, then reconfigure the I2C clock settings after the I2c_Open() API.
    essentially, you're dropping back to driverlib calls to configure the clock settings from here.
    -Bob L.
  • Hey Bob,

    Thanks for the info, I'll try that out.
  • Hello Bob,

    I have tried what you said, but I am still having some problems. I set the clock to run at 120MHz, and I tired to change the I2C clock speed after the I2C_open() API as instructed, but the clock speed did not change.... I made this change with the following command:

    /* Create I2C for usage at High Speed mode*/
    I2C_Params_init(&i2cParams);
    i2cParams.bitRate = I2C_3330kHz;
    i2c = I2C_open(Board_I2C_TMP, &i2cParams);

    /*Change I2C speed to desired value:*/
    MAP_I2CMasterInitExpClk(I2C0_BASE, 2900000, false);

    After this command the clock was still at 3.333MHz. Do you know what I am missing?
  • The 2nd parameter to MAP_I2CMasterInitExpClk() is not the I2C clock speed, it's the system speed.

    See the AppNote "Using Feature Set of I2C Master on SimpleLink™ MSP432E4 Microcontrollers", section 4.2 bullet 3 for a description of this API. 

    A colleague just pointed out that this speed needs to operate in "high-speed" mode, meaning there is a difference in how the IOs drive the bus between arbitration phase and data phase. Both the I2C MTPR.HS and .TPR bits would need to get set properly (HS=1, TPR=1). The closest frequency obtainable then would be 3.0Mbps not 2.9. 

    Note you will also need fairly low pullups to operate at this speed. 

    Try the above and see if that works. Note we are quickly getting away from TI drivers if we start editing too many of the settings, which likely will result in more unintended behavior. 

    If you'd like to discuss this more, please PM me.

    -Bob L. 

**Attention** This is a public forum