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.

OMAP L138 I2C issue ICXRDY not setting '1', always 0 after transmission

Other Parts Discussed in Thread: OMAPL138

 Hi

In my current board having OMAPL138 Iam facing problem for I2C write

i have initialize pin mux 4 for I2C0 signals

Iam using the same driver API's from LogicPd experimeter for I2C

My code looks like this

I2C_init(I2C0, I2C_CLK_100K);
   
    i2c_data[0] = 0x01;
    i2c_data[1] = 0x02;
   
   
ret = I2C_write(I2C0, 0x90, i2c_data, 1, 0x1);

But the below condition is always satisfied in I2C code ie ICXRDY is always 0 after i write a data in register

if (cnt++ > I2C_TIMEOUT)
            {
               // timed out waiting for data...reinit and return error.
               I2C_init(i2c, g_clock_rate);
               return (ERR_TIMEOUT);
            }

so the I2C gets reinit everytime.. Kindly suggest me what could be issue

Regards

Vijayabharathi

 

 

  • I would recommend the examples found in StarterWare as a place to go for reference code. If you still have issues you can reply here.

    Jeff

  • Hi

     

    Thanks for the suggestions.. in my code whether i miss below..

    Enable I2C clock from the Power and Sleep Controller if it is driven by Power and Sleep Controller
    (see your device-specific System Reference Guide).

    if means kindly help me how to enable this feature

    Regards

    Vijayabharathi C

  • That does not apply to this device. The StarterWare example will show you step by step how to enable everything necessary.

    Jeff

  • I have tried with the below code also.. No fruitful results.. Kindly suggest me how to solve this issue..

     

    http://processors.wiki.ti.com/index.php/QuickStartOMAPL1x_rCSL

     

     

    Iam currently using the hawk board for this.. Is hawk board have any issue for this I2C0.. we have even removed the components sharing I2C0 and tested the bit banging for I2C by using as GPIO for I2C emulation. bit banging for I2C0 is working perfectly. But for our current experiement we need hardware I2C to work because of  speed limitation for another applicationrunning parallel. Kindly suggest me how to solve this issue..

  • /*-----------------------------------------------------------------------------
     *
     *                 BEGIN EXAMPLE: I2C_io_expander_armL138
     *
     *---------------------------------------------------------------------------*/
    void main (void)
    {
        // Initialize OMAPL138 EVM (Configure Pins with I2C; I2C with ARM)
        init_OMAPL138();
       
        // Configure the I2C Peripheral
        setup_I2C0();
       
        // Configure the IO Expander
        setup_OMAPL138_io_expander();
       
        // Run Example
    //    I2C_io_expander_ARMexample();
    }/* End of main */


    /*-----------------------------------------------------------------------------
     *
     *                         Internal Functions Defined
     *
     *---------------------------------------------------------------------------*/
    static void init_OMAPL138 (void)
    {
        // Intrinsic Function; Gain 'supervisor' privileges
        _call_swi(ARM_PRIV_MODE_KEY);
       
        // Open Permissions to SYSCFG Registers
        CSL_FINS(sysRegs->KICK0R, SYSCFG_KICK0R_KICK0, KICK0_KEY);
        CSL_FINS(sysRegs->KICK1R, SYSCFG_KICK1R_KICK1, KICK1_KEY);
       
        // Configure I2C0 Data & Clock Signals
        CSL_FINST(sysRegs->PINMUX4, SYSCFG_PINMUX4_PINMUX4_15_12, I2C0_SDA);
        CSL_FINST(sysRegs->PINMUX4, SYSCFG_PINMUX4_PINMUX4_11_8, I2C0_SCL);
       
        // Configure I2C0 with the ARM CPU
        CSL_FINST(sysRegs->SUSPSRC, SYSCFG_SUSPSRC_I2C0SRC, ARM);
       
        // Close Permissions to SYSCFG Registers
        CSL_FINS(sysRegs->KICK0R, SYSCFG_KICK0R_KICK0, KICK_LOCK);
    }/* init_OMAPL138 */

    /*---------------------------------------------------------------------------*/

    static void setup_I2C0 (void)
    {
        // Place I2C in Reset
        CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_IRS, DISABLE);
       
        // Configure I2C Mode (Select 7-Bit Addressing & Transfer 8 Bits)
        CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_XA, 7BIT);
        CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_BC, 8BIT);
       
        // Disable Other I2C Modes (Repeat, Loopback, Free Data, Start Byte)
        CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_RM, DISABLE);
        CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_DLB, DISABLE);
        CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_FDF, DISABLE);
        CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_STB, DISABLE);
       
        // Configure I2C Clock Operation Freq (MUST BE BETWEEN 6.7 AND 13.3 MHz)
        CSL_FINS(i2c0Regs->ICPSC, I2C_ICPSC_IPSC, DIVto12MHZ);
       
        // Configure Clock Low/High Time (20 kHz)
        CSL_FINS(i2c0Regs->ICCLKL, I2C_ICCLKL_ICCL, 294);
        CSL_FINS(i2c0Regs->ICCLKH, I2C_ICCLKH_ICCH, 294);
       
        // Disable and Clear Pending I2C Interrupts
        i2c0Regs->ICIMR = CSL_I2C_ICIMR_RESETVAL;
        i2c0Regs->ICSTR = i2c0Regs->ICSTR;
       
        // Remove I2C from Reset
        CSL_FINST(i2c0Regs->ICMDR, I2C_ICMDR_IRS, ENABLE);
    }/* setup_I2C0 */

    /*---------------------------------------------------------------------------*/

    static void setup_OMAPL138_io_expander (void)
    {
        int k;
        // Write to the Port 0 Output Register
        writeIoExpCmd[COMMAND_BYTE] = 0x02;
       
        // Configure LED1 as Output
        writeIoExpCmd[DATA_BYTE] = 0x01;
       
        // Send Address/Data to IO Expander
        while(I2C_write(0x90, writeIoExpCmd, sizeof(writeIoExpCmd)));
    /*    for(k=0;k<100;k++)
        {
            I2C_write(0x90, writeIoExpCmd, sizeof(writeIoExpCmd));
        }*/
       
        // Read from the Port 1 Input Register
        readIoExpCmd[COMMAND_BYTE] = INPUT_PORT1;
       
        // Send Address to IO Expander
        while(I2C_write(I2C_IO_EXPANDER_ADDR, readIoExpCmd, sizeof(readIoExpCmd)));
       
        // Read from IO Expander
        while(I2C_read(I2C_IO_EXPANDER_ADDR, inputRegP1, sizeof(inputRegP1)));
       
        // Save DIP Switch Configuration for Later Use
        prevInputP1 = inputRegP1[0] & userSW1;
    }/* setup_OMAPL138_io_expander */

     

    Code hangs in this statement and continues in infinite state for long

    while(I2C_write(0x90, writeIoExpCmd, sizeof(writeIoExpCmd)));

    When i probed the I2C lines, i found some continuous activity going on there.. But if i execute same thing in single step, no activity in I2C lines

  • while(I2C_write(0x90, writeIoExpCmd, sizeof(writeIoExpCmd)));


    Where 0x90 is the device address and 0x02,0x01 are reg address and data to be written

  • Again, I would suggest you use the StarterWare examples, as these have been verified to work on the Hawkboard. Let me know if those do not work.

    Jeff