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.

Compiler/TMS320C6654: I2C bit rate is not as expected

Part Number: TMS320C6654

Tool/software: TI C/C++ Compiler

Hi,

I noticed that the software bit rate configuration of DSP is different from actual frequency of I2C clock.

I use provided I2C driver from TI and my relevant configuration is the following.

void initI2C(){
    I2C_HwAttrs   i2c_cfg;
    /* Get the default I2C init configurations */
    I2C_socGetInitCfg(0, &i2c_cfg);
    I2C_Params_init(&i2cParams);
    I2C_transactionInit(&i2cTransaction);
}

int i2c_doProcess(I2C_FUNCPtr i2cSetup){
    volatile int ret = 1;
    initI2C();
    i2c_bitrateSet(I2C_400kHz);
    i2c_handle = I2C_open(0, &i2cParams);

    /* peripheral setting */
    i2cSetup(&i2cTransaction);

    int status = I2C_transfer(i2c_handle, &i2cTransaction);

    if(!status){
        ret = 0;
    }

    I2C_close(i2c_handle);

    return ret;
}

As above, software configuration is I2C_400kHz however actual freq is approximately 330kHz.

At the default case, expected value is 100kHz however actual freq is approximately 90kHz.

Why does the differ cause ?

  • Hi,

    Check Section 2.3 Clock Generation in the I2C User Guide:

    Check the device PLL configurations? Also check the Prescaler & ICCL/ICCH values.


    Best Regards,
    Yordan

  • Hi,

    Sorry, I forgot to configure the I2C_HwAttrs sstructure so I revised my source code as the following.

    void initI2C(){
        I2C_HwAttrs   i2c_cfg;
        /* Get the default I2C init configurations */
        I2C_socGetInitCfg(0, &i2c_cfg);
        i2c_cfg.funcClk = (850000000 / 6); //revised
        I2C_socSetInitCfg(0, &i2c_cfg); //revised
        I2C_Params_init(&i2cParams);
        I2C_transactionInit(&i2cTransaction);
    }

    Then measured the waveform, 103.8kHz as 100kHz configuration and 403.2kHz as 400kHz configuration.

    There are still difference between expected value and actual value however is this reasonable ?

    regards,

  • Hi,

    I suggest you read the prescaler, scll and sclh register values and calculate as explained in the user guide. The register values might need some tuning.


    Best Regards,
    Yordan