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.

TMS320F280049: I2CPSC needs setting when F28004x used as slave

Part Number: TMS320F280049
Other Parts Discussed in Thread: SYSCONFIG, C2000WARE

Dear Champs,

Does I2CPSC needs to be set so that I2C clock is in between 7-12 MHz?

Which driverlib API is used for this I2CPSC setting?

It seems I do not see this setting when using SYSCONFIG GUI for I2C initialization.

Would you please help show me explicitly?

Wayne Huang

  • Wayne,

    Does I2CPSC needs to be set so that I2C clock is in between 7-12 MHz?

    Yes, I2CPSC must be set appropriately to set the I2C module clock between 7-12 MHz.

    Which driverlib API is used for this I2CPSC setting?

    I2C_initMaster is the driverlib function used to set I2CPSC setting.

    Code generated by sysconfig (board.c) does use I2C_initMaster  as shown below. This function automatically take care of setting I2C module clock between 7-12 MHz based on DEVICE_SYSCLK_FREQ and 400 KHz. settings shown below.

    I2C_initMaster(myI2C0_BASE, DEVICE_SYSCLK_FREQ, 400000, I2C_DUTYCYCLE_50);

    Regards,

    Manoj

  • Dear Manoj,

    Do you mean even I2C acts as "slave", the user still needs to call "I2C_initMaster(myI2C0_BASE, DEVICE_SYSCLK_FREQ, 400000, I2C_DUTYCYCLE_50);"?

    I do not see this by Sysconfig. would you please confirm it?

    like below generated by Sysconfig....

    void I2C_init(){
    //myI2C0 initialization

    I2C_disableModule(myI2C0_BASE);
    I2C_setConfig(myI2C0_BASE, I2C_SLAVE_RECEIVE_MODE);
    I2C_setOwnSlaveAddress(myI2C0_BASE, 60);
    I2C_setBitCount(myI2C0_BASE, I2C_BITCOUNT_8);
    I2C_setDataCount(myI2C0_BASE, 1);
    I2C_setAddressMode(myI2C0_BASE, I2C_ADDR_MODE_7BITS);
    I2C_disableFIFO(myI2C0_BASE);
    I2C_clearInterruptStatus(myI2C0_BASE, I2C_INT_RX_DATA_RDY | I2C_INT_TX_DATA_RDY);
    I2C_enableInterrupt(myI2C0_BASE, I2C_INT_RX_DATA_RDY | I2C_INT_TX_DATA_RDY);
    I2C_setEmulationMode(myI2C0_BASE, I2C_EMULATION_STOP_SCL_LOW);
    I2C_enableModule(myI2C0_BASE);

    }

    Wayne

  • Wayne,

    I didn't realize you are working in I2C slave mode. I did get the same I2C initialization for slave configuration. This is a bug and needs to be fixed.

    I2C Module clock needs to between 7-12 MHz for I2C to work correctly.

    Let me check with sysconfig expert and get it fixed. We are very close to 3Q C2000Ware. Let me see whether I can get it fixed in 3Q release. If not, we shall definitely update in 1Q 2022.

    Regards,

    Manoj