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.

Setting up I2C for custom target using OMAP-L138

Other Parts Discussed in Thread: TPS65910, OMAPL138

All:

We have been using the LCDK138 up until the target board became available. It has a PMIC chip on board, something that LCDK138 did not have. (TPS65910)

On the LCDK board, the only I2C example was the "game" example, which I was able to pare down to be able to initialize and read a register from AIC31.

As a starting point, I wanted to change that example to read JTAGVERNUM_REG (0x80) or another register such as DEVCTRL_REG (0x40).

Questions:

1. I2CMasterInitExpClk(SOC_I2C_0_REGS, 50000000, 10000000, speed); where speed is 100000  Is this set up correctly? The base addresses should be the same, the input clock is 50 MHz, and the "divisor" is picked at 10 MHz.

2. I2C Slave Address of TPS65910 - from my readings, this should be 0x2D - is this correct?

 

  • Hi Todd,
    You can refer to the following I2C examples from OMAPL138 Starterware location.

    C:\ti\OMAPL138_StarterWare_1_10_04_01\examples\evmOMAPL138\i2c
    C:\ti\OMAPL138_StarterWare_1_10_04_01\examples\evmOMAPL138\i2c_edma


    1. I2CMasterInitExpClk(SOC_I2C_0_REGS, 50000000, 10000000, speed); where speed is 100000 Is this set up correctly? The base addresses should be the same, the input clock is 50 MHz, and the "divisor" is picked at 10 MHz.

    Yes, you are right.

    C:\ti\OMAPL138_StarterWare_1_10_04_01\drivers\hsi2c.c

    /**
    * \brief This API will divide the system clock fed to I2C module between
    * 12 and 100Mhz.It will also configure the I2C bus clock frequency.
    *
    * \param baseAdd It is the Memory address of the I2C instance used.
    * \param sysClk It is the System clock fed to I2C module.
    * \param internalClk It is the internal clock used by I2C module.Which is
    * obtained by scaling System clock fed to I2C module.
    * \param outputClk It is the required I2C bus speed or frequency.
    *
    * \return None.
    **/
    void I2CMasterInitExpClk(unsigned int baseAdd, unsigned int sysClk,
    unsigned int internalClk, unsigned int outputClk)
    {
    unsigned int prescalar;
    unsigned int divider;

    /* Calculate prescalar value */
    prescalar = (sysClk / internalClk) - 1;

    HWREG(baseAdd + I2C_PSC) = prescalar;

    divider = internalClk/outputClk;

    divider = divider / 2;

    HWREG(baseAdd + I2C_SCLL) = divider - 7;

    HWREG(baseAdd + I2C_SCLH) = divider - 5;
    }



    2. I2C Slave Address of TPS65910 - from my readings, this should be 0x2D - is this correct?

    Yes.

    lkml.org/.../416

    www.ti.com/.../tps65910.pdf

    page no 56:
    6.8 I2C Interface:
    A general-purpose serial control interface (CTL-I2C) allows read and write access to the configurationregisters of all resources of the system.
    A second serial control interface (SR-I2C) is dedicated to SmartReflex applications such as DVFS or AVS.
    Both control interfaces are compliant with HS-I2C specification.
    These interfaces support the standard slave mode (100 Kbps), Fast mode (400 Kbps), and high-speed
    mode (3.4 Mbps). The general-purpose I2C module using one slave hard-coded address (ID1 = 2Dh). The
    SmartReflex I2C module uses one slave hard-coded address (ID0 = 12h). The master mode is notsupported.
  • If I want to query a register in the PMIC (like DEVCTRL2_REG at address 0x40), would I need to create a function like SetupI2CTransmit( )?

    SetupI2CReceive()?

     

    static void SetupI2CTransmit(void)
    {
        I2CSetDataCount(SOC_I2C_0_REGS, 2);

        I2CMasterControl(SOC_I2C_0_REGS, I2C_CFG_MST_TX | I2C_CFG_STOP);

        I2CMasterIntEnableEx(SOC_I2C_0_REGS, I2C_INT_TRANSMIT_READY|I2C_INT_STOP_CONDITION);

        I2CMasterStart(SOC_I2C_0_REGS);
    }

    sorry, I am used to having a few functions available like this...