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.

TM4C1290NCPDT: TIVA: How can I set I2C frequency

Part Number: TM4C1290NCPDT

Hello,

My TIVA is connected to few I2C slaves via I2C8, I2C2

I called:

uiSysSycClock  = SysCtlClockFreqSet (SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480, 120000000)

I had to change 120,000,000 to 10,000,000 in order  to work with I2C.

What is the right way to change I2C frequency to 100KHz or 400KHz ?

Thank you,

Zvika 

  • Hi,

    uiSysSycClock  = SysCtlClockFreqSet (SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480, 120000000)

    I notice that you use SYSCTL_CFG_VCO_480. It seems to suggest you are using an older TivaWare? The latest TivaWare is v2.2.0.295 which can be downloaded from https://www.ti.com/tool/SW-TM4C. While there is no issue to use SYSCTL_CFG_VCO_480, there are several improvements (e.g. bug fixes and a few more examples) in the latest TivaWare. 

    I had to change 120,000,000 to 10,000,000 in order  to work with I2C.

    What is the right way to change I2C frequency to 100KHz or 400KHz ?

    You can keep the System Clock at 120Mhz and use I2CMasterInitExpClk() to specify I2C frequency for either 100k or 400kHz. See below. 

      For example, 

    I2CMasterInitExpClk(I2C8_BASE, uiSysSycClock  , false); // Set I2C8 for 100kHz

    I2CMasterInitExpClk(I2C8_BASE, uiSysSycClock  , true); // Set I2C8 for 400kHz