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.

I2C cannot work

Hi all

This is my  i2c register config according to datasheet

#define I2C0_BASE 0x48028000
#define I2C0_REV *( volatile Uint32* )( I2C0_BASE + 0x00 )
#define I2C0_IE *( volatile Uint32* )( I2C0_BASE + 0x84 )
#define I2C0_STAT *( volatile Uint32* )( I2C0_BASE + 0x28 )
#define I2C0_WE *( volatile Uint32* )( I2C0_BASE + 0x34 )
#define I2C0_SYSS *( volatile Uint32* )( I2C0_BASE + 0x90 )
#define I2C0_BUF *( volatile Uint32* )( I2C0_BASE + 0x94 )
#define I2C0_CNT *( volatile Uint32* )( I2C0_BASE + 0x98 )
#define I2C0_DATA *( volatile Uint32* )( I2C0_BASE + 0x9c )
#define I2C0_SYSC *( volatile Uint32* )( I2C0_BASE + 0xa0 )
#define I2C0_CON *( volatile Uint32* )( I2C0_BASE + 0xa4 )
#define I2C0_OA *( volatile Uint32* )( I2C0_BASE + 0xa8 )
#define I2C0_SA *( volatile Uint32* )( I2C0_BASE + 0xac )
#define I2C0_PSC *( volatile Uint32* )( I2C0_BASE + 0xb0 )
#define I2C0_SCLL *( volatile Uint32* )( I2C0_BASE + 0xb4 )
#define I2C0_SCLH *( volatile Uint32* )( I2C0_BASE + 0xb8 )
#define I2C0_SYSTEST *( volatile Uint32* )( I2C0_BASE + 0xbc )

when I run the demo, the function EVM816x_I2C0_write() return 2002, I debug the problem is the status of the  I2C0_STAT does not change, so why it does not change? how should I can do for that?

thanks

zhong 

  • Zhong,

    Can you describe the problem clearly? Its very difficult to understand what exactly you are trying out on I2C0. What is the software stack that you are using? Is it Linux?

  • Hi Renjith,

    Thanks for you replay. 

          The problem is that I have a chip loaded on I2C in dm8168 ,it's  i2c address is 0x55. I want to use I2C0 getting the chip ID. I load a ccs test program of dm816x, I see there is a test demo i2c_mapper. Of course, the demo is not woking in my SEED-XDS560 simulator, so I create a c6000 project according to the demo i2c_mapper.There are my files, could you please check them out for me how should I modify it,thanks very much. 

          6837.evm8168.h6366.evm8168_i2c.h

    /*
     * main.c
     */
    
    /*
     *  Copyright 2010 by Spectrum Digital Incorporated.
     *  All rights reserved. Property of Spectrum Digital Incorporated.
     */
    
    /*
     *  I2C implementation
     *
     */
    
    #include "evm8168.h"
    #include "evm8168_i2c.h"
    #include "stdio.h"
    
    /* ------------------------------------------------------------------------ *
     *  EVM8168_I2C0_init( )                                                      *
     *      Initialize I2C - self address is 0xCC                               *
     *                                                                          *
     *      The interrupts are not configured b/c this example will only deal   *
     *      with polling.                                                       *
     * ------------------------------------------------------------------------ */
    void EVM8168_I2C0_init( )
    {
        Uint16 selfAddress = 0xCC;
    
        /* Disable I2C and set to default state */
        I2C0_CON = 0;
    
        EVM8168_waitusec( 500 );
    
        /* Disable interrupts */
        I2C0_IE = 0;
    
        /* Set Clock Prescaler ( since CK_REF = 12MHz ) no scale down needed */
        I2C0_PSC = 0xff;
    
        /* Set SCL low time & SCL high time */
        /* ( 12MHz clock / ( 400kHz i2c clk * 2 ) ) minus 6 for reg. setting */
        /* Equivalent to ( ( 12 * 1000 ) / ( 400 * 2 ) ) - 6; */
        I2C0_SCLH = I2C0_SCLL = 9;
    
        /* Set Own Address - cannot conflict with other devices addresses */
        I2C0_OA = selfAddress & I2C_OA_MASK;
    
        /* Enable I2C */
        I2C0_CON = I2C_CON_I2C_EN;
    
        /* Set the Slave address to 0, this is only temporary */
        I2C0_SA = 0;
    
        /* Set Data Count */
        I2C0_CNT = 0;
    
        I2C0_STAT = 16;
    
        /* Enable interrupts */
        /* NOTE: for this example, polling is used instead of interrupts */
        I2C0_IE = 0
              //| I2C0_IE_GC_IE      // General Call
              //| I2C0_IE_XRDY_IE    // Transmit Data Ready
              //| I2C0_IE_RRDY_IE    // Receive Data Ready
              //| I2C0_IE_ARDY_IE    // Register Access Ready
              //| I2C0_IE_NACK_IE    // No Acknowledgement
              //| I2C0_IE_AL_IE      // Arbitration Lost
                ;
    }
    
    /* ------------------------------------------------------------------------ *
     *  EVM8168_I2C0_read( slave_addr, data, length )                             *
     *      Read from I2C                                                       *
     *      Returns:                                                            *
     *          0 - Pass                                                        *
     *          1001 - Fail ( Errors - Arbitration Lost )                       *
     *          1002 - Fail ( Errors - NACK )                                   *
     *          2001 - Fail ( Timeout - Bus Busy )                              *
     *          2002 - Fail ( Timeout - Read )                                  *
     * ------------------------------------------------------------------------ */
    Uint16 EVM8168_I2C0_read( Uint16 slave_addr, Uint8* data, Uint16 length )
    {
        Uint8 *pdata = ( Uint8 * )data;
        Uint16 status;
        Int32 i, timecount, timeout = 0x1000;
    
        /* Set slave address */
        I2C0_SA = slave_addr;
    
        /* Set data count */
        I2C0_CNT = length;
    
        /* Poll BB field on I2C0_STAT - Wait for bus to become free */
        for ( i = 0 ; I2C0_STAT & I2C_STAT_BB ; i++ )
            if ( i > timeout )
                return 2001;
    
        /* Configure Options for Receiving - Master Reciever mode */
        I2C0_CON = 0
                | I2C_CON_I2C_EN    // I2C Enable
                | I2C_CON_MST       // Master Mode
                | I2C_CON_RX        // Receive Mode
                | I2C_CON_STP       // Stop
                | I2C_CON_STT       // Start
                ;
    
        /* Poll until complete */
        for ( timecount = 0 ; timecount < timeout ; timecount++ )
        {
            /* Read I2C Status register */
            status = I2C0_STAT;
    
            /* Check for NACK */
            if ( ( status & I2C_STAT_NACK ) != I2C_STAT_NACK )
            {
                /* Check for ARDY */
                if ( ( status & I2C_STAT_ARDY ) != I2C_STAT_ARDY )
                {
                    /* Check for RRDY */
                    if ( ( status & I2C_STAT_RRDY ) == I2C_STAT_RRDY )
                    {
                        /* Read Data */
                        if ( length == 1 )
                        {
                            *pdata = I2C0_DATA & 0xFF;
                            length--;
                        }
                        else
                        {
                            *pdata++ = I2C0_DATA;
                            length -= 1;
                        }
    
                        /* Clear Receive Ready field */
                        I2C0_STAT &= I2C_STAT_RRDY;
                    }
                }
    
                /* Check for Errors - refresh status register */
                status = I2C0_STAT;
    
                /* Check for Arbitration Lost */
                if ( ( status  & I2C_STAT_AL ) == I2C_STAT_AL )
                {
                    I2C0_STAT &= I2C_STAT_AL;
                    return 1001;
                }
    
                /* Check for NACK */
                if ( ( status & I2C_STAT_NACK ) == I2C_STAT_NACK )
                {
                    I2C0_STAT &= I2C_STAT_NACK;
                    return 1002;
                }
    
                /* Check for Register Access Ready - Good Condition */
                if ( ( I2C0_STAT & I2C_STAT_ARDY ) == I2C_STAT_ARDY )
                {
                    I2C0_STAT &= I2C_STAT_ARDY;
                    return 0;
                }
                _waitusec( 1000 );
            }
        }
    
        /* I2C Timeout */
        return 2002;
    }
    
    /* ------------------------------------------------------------------------ *
     *  EVM8168_I2C0_write( slave_addr, data, length )                            *
     *      Write to I2C                                                        *
     *      Returns:                                                            *
     *          0 - Pass                                                        *
     *          1001 - Fail ( Errors - Arbitration Lost )                       *
     *          1002 - Fail ( Errors - NACK )                                   *
     *          2001 - Fail ( Timeout - Bus Busy )                              *
     *          2002 - Fail ( Timeout - Write )                                 *
     * ------------------------------------------------------------------------ */
    Uint16 EVM8168_I2C0_write( Uint16 slave_addr, Uint8* data, Uint16 length )
    {
        Uint8 *pdata = ( Uint8 * )data;
        Uint8 last_byte = ( data[length-1] & 0xFF );
        Uint16 status;
        Int16 i, timecount, timeout = 0x1000;
        I2C0_STAT = 0;
        /* Set slave address */
        I2C0_SA = slave_addr;
    
        /* Set data count */
        I2C0_CNT = length;
    
        /* Poll BB field on I2C0_STAT - Wait for bus to become free */
        for ( i = 0 ; I2C0_STAT & I2C_STAT_BB ; i++ )
            if ( i > timeout )
                return 2001;
    
        /* Configure Options for Transmitting - Master Transmit mode */
        I2C0_CON = 0
                | I2C_CON_I2C_EN    // I2C Enable
                | I2C_CON_MST       // Master Mode
                | I2C_CON_TX        // Transmit Mode
                | I2C_CON_STP       // Stop
                | I2C_CON_STT       // Start
                ;
    
        /* Poll until complete */
        for ( timecount = 0 ; timecount < timeout ; timecount++ )
        {
            /* Read I2C Status register */
            status = I2C0_STAT;
    
            /* Check for NACK */
            if ( ( status & I2C_STAT_NACK ) != I2C_STAT_NACK )
            {
                /* Check for ARDY */
                if ( ( status & I2C_STAT_ARDY ) != I2C_STAT_ARDY )
                {
                    /* Check for XRDY */
                    if ( ( status & I2C_STAT_XRDY ) == I2C_STAT_XRDY )
                    {
                        /* Send Data */
                        if ( length == 1 )
                        {
                            I2C0_DATA = last_byte;
                            length--;
                        }
                        else
                        {
                            I2C0_DATA = *pdata++;
                            length -= 1;
                        }
    
                        /* Clear Transmit Ready field */
                        I2C0_STAT &= I2C_STAT_XRDY;
                    }
                }
    
                /* Check for Errors - refresh status register */
                status = I2C0_STAT;
    
                /* Check for Arbitration Lost */
                if ( ( status  & I2C_STAT_AL ) == I2C_STAT_AL )
                {
                    I2C0_STAT &= I2C_STAT_AL;
                    return 1001;
                }
    
                /* Check for NACK */
                if ( ( status & I2C_STAT_NACK ) == I2C_STAT_NACK )
                {
                    I2C0_STAT &= I2C_STAT_NACK;
                    return 1002;
                }
    
                /* Check for Register Access Ready - Good Condition */
                if ( ( I2C0_STAT & I2C_STAT_ARDY ) == I2C_STAT_ARDY )
                {
                    I2C0_STAT &= I2C_STAT_ARDY;
                    return 0;
                }
                I2C0_CON |= 0x02;
                _wait( 1000 );
            }
        }
    
        /* I2C Timeout */
        return 2002;
    }
    
    /* ------------------------------------------------------------------------ *
     *  EVM8168_I2C1_init( )                                                      *
     *      Initialize I2C - self address is 0xCC                               *
     *                                                                          *
     *      The interrupts are not configured b/c this example will only deal   *
     *      with polling.                                                       *
     * ------------------------------------------------------------------------ */
    void EVM8168_I2C1_init( )
    {
        Uint16 selfAddress = 0xCC;
    
        /* Disable I2C and set to default state */
        I2C1_CON = 0;
    
        EVM8168_waitusec( 500 );
    
        /* Disable interrupts */
        I2C1_IE = 0;
    
        /* Set Clock Prescaler ( since CK_REF = 12MHz ) no scale down needed */
        I2C1_PSC = 0xff;
    
        /* Set SCL low time & SCL high time */
        /* ( 12MHz clock / ( 400kHz i2c clk * 2 ) ) minus 6 for reg. setting */
        /* Equivalent to ( ( 12 * 1000 ) / ( 400 * 2 ) ) - 6; */
        I2C1_SCLH = I2C1_SCLL = 9;
    
        /* Set Own Address - cannot conflict with other devices addresses */
        I2C1_OA = selfAddress & I2C_OA_MASK;
    
        /* Enable I2C */
        I2C1_CON = I2C_CON_I2C_EN;
    
        /* Set the Slave address to 0, this is only temporary */
        I2C1_SA = 0;
    
        /* Set Data Count */
        I2C1_CNT = 0;
    
        /* Enable interrupts */
        /* NOTE: for this example, polling is used instead of interrupts */
        I2C1_IE = 0
              //| I2C1_IE_GC_IE      // General Call
              //| I2C1_IE_XRDY_IE    // Transmit Data Ready
              //| I2C1_IE_RRDY_IE    // Receive Data Ready
              //| I2C1_IE_ARDY_IE    // Register Access Ready
              //| I2C1_IE_NACK_IE    // No Acknowledgement
              //| I2C1_IE_AL_IE      // Arbitration Lost
                ;
    }
    
    /* ------------------------------------------------------------------------ *
     *  EVM8168_I2C1_read( slave_addr, data, length )                             *
     *      Read from I2C                                                       *
     *      Returns:                                                            *
     *          0 - Pass                                                        *
     *          1001 - Fail ( Errors - Arbitration Lost )                       *
     *          1002 - Fail ( Errors - NACK )                                   *
     *          2001 - Fail ( Timeout - Bus Busy )                              *
     *          2002 - Fail ( Timeout - Read )                                  *
     * ------------------------------------------------------------------------ */
    Uint16 EVM8168_I2C1_read( Uint16 slave_addr, Uint8* data, Uint16 length )
    {
        Uint8 *pdata = ( Uint8 * )data;
        Uint16 status;
        Int32 i, timecount, timeout = 0x1000;
    
        /* Set slave address */
        I2C1_SA = slave_addr;
    
        /* Set data count */
        I2C1_CNT = length;
    
        /* Poll BB field on I2C1_STAT - Wait for bus to become free */
        for ( i = 0 ; I2C1_STAT & I2C_STAT_BB ; i++ )
            if ( i > timeout )
                return 2001;
    
        /* Configure Options for Receiving - Master Reciever mode */
        I2C1_CON = 0
                | I2C_CON_I2C_EN    // I2C Enable
                | I2C_CON_MST       // Master Mode
                | I2C_CON_RX        // Receive Mode
                | I2C_CON_STP       // Stop
                | I2C_CON_STT       // Start
                ;
    
        /* Poll until complete */
        for ( timecount = 0 ; timecount < timeout ; timecount++ )
        {
            /* Read I2C Status register */
            status = I2C1_STAT;
    
            /* Check for NACK */
            if ( ( status & I2C_STAT_NACK ) != I2C_STAT_NACK )
            {
                /* Check for ARDY */
                if ( ( status & I2C_STAT_ARDY ) != I2C_STAT_ARDY )
                {
                    /* Check for RRDY */
                    if ( ( status & I2C_STAT_RRDY ) == I2C_STAT_RRDY )
                    {
                        /* Read Data */
                        if ( length == 1 )
                        {
                            *pdata = I2C1_DATA & 0xFF;
                            length--;
                        }
                        else
                        {
                            *pdata++ = I2C1_DATA;
                            length -= 1;
                        }
    
                        /* Clear Receive Ready field */
                        I2C1_STAT &= I2C_STAT_RRDY;
                    }
                }
    
                /* Check for Errors - refresh status register */
                status = I2C1_STAT;
    
                /* Check for Arbitration Lost */
                if ( ( status  & I2C_STAT_AL ) == I2C_STAT_AL )
                {
                    I2C1_STAT &= I2C_STAT_AL;
                    return 1001;
                }
    
                /* Check for NACK */
                if ( ( status & I2C_STAT_NACK ) == I2C_STAT_NACK )
                {
                    I2C1_STAT &= I2C_STAT_NACK;
                    return 1002;
                }
    
                /* Check for Register Access Ready - Good Condition */
                if ( ( I2C1_STAT & I2C_STAT_ARDY ) == I2C_STAT_ARDY )
                {
                    I2C1_STAT &= I2C_STAT_ARDY;
                    return 0;
                }
                _waitusec( 1000 );
            }
        }
    
        /* I2C Timeout */
        return 2002;
    }
    
    /* ------------------------------------------------------------------------ *
     *  EVM8168_I2C1_write( slave_addr, data, length )                            *
     *      Write to I2C                                                        *
     *      Returns:                                                            *
     *          0 - Pass                                                        *
     *          1001 - Fail ( Errors - Arbitration Lost )                       *
     *          1002 - Fail ( Errors - NACK )                                   *
     *          2001 - Fail ( Timeout - Bus Busy )                              *
     *          2002 - Fail ( Timeout - Write )                                 *
     * ------------------------------------------------------------------------ */
    Uint16 EVM8168_I2C1_write( Uint16 slave_addr, Uint8* data, Uint16 length )
    {
        Uint8 *pdata = ( Uint8 * )data;
        Uint8 last_byte = ( data[length-1] & 0xFF );
        Uint16 status;
        Int16 i, timecount, timeout = 0x1000;
    
        /* Set slave address */
        I2C1_SA = slave_addr;
    
        /* Set data count */
        I2C1_CNT = length;
    
        /* Poll BB field on I2C1_STAT - Wait for bus to become free */
        for ( i = 0 ; I2C1_STAT & I2C_STAT_BB ; i++ )
            if ( i > timeout )
                return 2001;
    
        /* Configure Options for Transmitting - Master Transmit mode */
        I2C1_CON = 0
                | I2C_CON_I2C_EN    // I2C Enable
                | I2C_CON_MST       // Master Mode
                | I2C_CON_TX        // Transmit Mode
                | I2C_CON_STP       // Stop
                | I2C_CON_STT       // Start
                ;
    
        /* Poll until complete */
        for ( timecount = 0 ; timecount < timeout ; timecount++ )
        {
            /* Read I2C Status register */
            status = I2C1_STAT;
    
            /* Check for NACK */
            if ( ( status & I2C_STAT_NACK ) != I2C_STAT_NACK )
            {
                /* Check for ARDY */
                if ( ( status & I2C_STAT_ARDY ) != I2C_STAT_ARDY )
                {
                    /* Check for XRDY */
                    if ( ( status & I2C_STAT_XRDY ) == I2C_STAT_XRDY )
                    {
                        /* Send Data */
                        if ( length == 1 )
                        {
                            I2C1_DATA = last_byte;
                            length--;
                        }
                        else
                        {
                            I2C1_DATA = *pdata++;
                            length -= 1;
                        }
    
                        /* Clear Transmit Ready field */
                        I2C1_STAT &= I2C_STAT_XRDY;
                    }
                }
    
                /* Check for Errors - refresh status register */
                status = I2C1_STAT;
    
                /* Check for Arbitration Lost */
                if ( ( status  & I2C_STAT_AL ) == I2C_STAT_AL )
                {
                    I2C1_STAT &= I2C_STAT_AL;
                    return 1001;
                }
    
                /* Check for NACK */
                if ( ( status & I2C_STAT_NACK ) == I2C_STAT_NACK )
                {
                    I2C1_STAT &= I2C_STAT_NACK;
                    return 1002;
                }
    
                /* Check for Register Access Ready - Good Condition */
                if ( ( I2C1_STAT & I2C_STAT_ARDY ) == I2C_STAT_ARDY )
                {
                    I2C1_STAT &= I2C_STAT_ARDY;
                    return 0;
                }
                //I2C1_CON |= 0x02;
                _wait( 1000 );
            }
        }
    
        /* I2C Timeout */
        return 2002;
    }
    
    
    Int16 EVM8168_init( )
    {
        EVM8168_I2C0_init();
    	EVM8168_I2C1_init();
        return 0;
    }
    
    /* ------------------------------------------------------------------------ *
     *                                                                          *
     *  _wait( delay )                                                          *
     *      Wait in a software loop for 'x' delay                               *
     *                                                                          *
     * ------------------------------------------------------------------------ */
    void EVM8168_wait( Uint32 delay )
    {
        volatile Uint32 i;
        for ( i = 0 ; i < delay ; i++ ){ };
    }
    
    /* ------------------------------------------------------------------------ *
     *                                                                          *
     *  _waitusec( usec )                                                       *
     *      Wait in a software loop for 'x' microseconds                        *
     *                                                                          *
     * ------------------------------------------------------------------------ */
    void EVM8168_waitusec( Uint32 usec )
    {
            EVM8168_wait( usec * 2 );
    }
    
    /* ------------------------------------------------------------------------ *
     *                                                                          *
     *  _waitmsec( msec )                                                       *
     *      Wait in a software loop for 'x' milliseconds                        *
     *                                                                          *
     * ------------------------------------------------------------------------ */
    void EVM8168_waitmsec( Uint32 msec )
    {
        _waitusec( 1000 * msec );
    }
    
    
    Int16 DAVINCIEVM_DS28CN_read( Uint8 src, Uint8 dst, Uint8 length)
    {
    
        Uint8 addr,flag;
        flag=0;
        addr = src;
    
        flag|=EVM8168_I2C0_write(0x55,&addr,1);
    
        flag|=EVM8168_I2C0_read(0x55, &dst,length);
         return dst;
    }
    
    int main(void) {
    	
    	printf("I2C begin\n");
    
    	int value;
    
    	unsigned char securityID[8];
    	//EVM8168_init( );
    	EVM8168_I2C0_init();
        unsigned char data[3];
        data[1]=0xA8;
        data[0]=0x00;
        value = EVM8168_I2C0_write(0x55,data,1);
    
        printf("write value = %d\n", value);
    
        if (0 == value)
        	printf("I2C_WRITE SUCCESS\n");
        else
        	printf("I2C_WRITE FAILED\n");
    
    
        //short i;
    
    //  read rom id
        //for(i=0;i<8;i++)
        //{
        //	securityID[i]=DAVINCIEVM_DS28CN_read(0xA0+i, securityID[i],1);
        //}
    
    
    
        value = EVM8168_I2C0_read(0x55, securityID, 1);
        printf("read value = %d\n", value);
    
        EVM8168_waitusec(50000);
    
    	printf("########## securityID = %x ##########\n", securityID);
    
    /*
    
    	EVM8168_init( );
    
       	Uint8 cmd[5];
        Int16 i, j;
    
        printf("This test prints out all the I2C0 devices detected.\n");
    
        for (i=0; i < 127; i++ )
        {
    
            //cmd[0] = 3 & 0x007F;       // 7-bit Device Address
            //cmd[1] = 0;
            j = EVM8168_I2C0_read( i, cmd, 1 );
    		if (j==0)
    		    printf("I2C address %x is valid\n",i);
    		else
    		{
    			printf("I2C address %x is not valid\n",i);
    		    EVM8168_I2C0_init( );
    		    I2C0_STAT |=2;
    		}
    
    		EVM8168_waitusec(50000);
        }
    */
    
    	return 0;
    }
    

    BR

    Zhong

  • Hi Renjith,

    I found a problem, why the default value of status(status = I2C0_STAT) is 66 (0x42 and 1000010),also it is the reason why the funtion EVM8168_I2C0_write() returns 2002. So, is it the I2C_STAT address wrong lead to wrong default status value? Thanks.

    BR

    Zhong

  • Zhong,

    I believe you are going in the wrong direction by writing your own sample application. You can get I2C working using Linux itself. Linux I2C driver is well tested and exists from several years.

    Can you confirm whether your device is connected to I2C0 itself? What is the behavior that you see when you use Linux?

    Regards,
    Renjith

  • Hi Renjith,

    Thanks for your timely replay.

    I am sure that my device is connected to I2C. When I test the linux i2c driver(i2c_mapper), it just stopped, no anything output,  I debug it stop in the function EVM816X_I2C0_init( ). So I do not know that is why it happen.

    BR

    Zhong

  • Zhong,

    Can you try to do i2c probe from u-boot prompt? Also can you check your schematics first to confirm whether you are using I2C0 or I2C1?

  • Renjith,

    How to do i2c probe from u-boot prompt? Is it confirm that whether my device is connected to I2C? I am using i2c0, but it can not work, so I have tried to use i2c1, and  getting the result is I2C0 and I2C1 both can not work.Thanks.

    Best Regards

    Zhong   

  • Yes, it is. run the command i2c probe  in u-boot. You can get help by "help i2c" command. If its not working with i2c probe, there is some other issue that you need to look at. Can you check whether your slave is powered up? Is there any reset sequence?

  • Renjith,

    I run the command i2c probe, getting a word, that is Valid chip addresses: 18  68

    So is it showed that there are just two valid chip address which are 0x18 and 0x68 could  be  used  by  i2c?

    Best Regards

    Zhong

  • Zhong,

    Can you try i2c dev 1 and do i2c probe again?

  • Renjith,

    Below is the output, Thanks.

    DBVT_UBOOT # i2c dev 1
    i2c - I2C sub-system

    Usage:
    i2c crc32 chip address[.0, .1, .2] count - compute CRC32 checksum
    i2c loop chip address[.0, .1, .2] [# of objects] - looping read of device
    i2c md chip address[.0, .1, .2] [# of objects] - read from I2C device
    i2c mm chip address[.0, .1, .2] - write to I2C device (auto-incrementing)
    i2c mw chip address[.0, .1, .2] value [count] - write to I2C device (fill)
    i2c nm chip address[.0, .1, .2] - write to I2C device (constant address)
    i2c probe - show devices on the I2C bus
    i2c read chip address[.0, .1, .2] length memaddress - read to memory
    i2c reset - re-init the I2C Controller
    i2c speed [speed] - show or set I2C bus speed
    DBVT_UBOOT # i2c probe
    Valid chip addresses: 18 68

    Best Regards

    Zhong

  • Looks like your version of u-boot doesn't support i2c dev command

    http://blackfin.uclinux.org/doku.php?id=bootloaders:u-boot:i2c

    Can share the portion of the schematics, that is connecting your slave device to DM816x? Also can you confirm if you are using I2C0, you are initializing or following the reset sequence correctly?

  • Renjith,

    Here is the schematics.

    When I run the linux I2C driver, is it need to do i2c0 initializing?

    There is a init function(EVM8168_I2C0_init()) in the demo, what else init I can do for I2C0?

    So, what do you mean that  'can you confirm if you are using I2C0, you are initializing or following the reset sequence correctly'? 

    Thanks.

    Best Regards

    Zhong

  • Zhong,

    If you are using DS28CN01 as slave, then its connected to I2C1. Also the address 0x55 doesn't seems to be correct according to A0, A1 pins. If its different can you share the slave side schematics as well?

  • Renjith,

    Thanks for your replay.

    The schematics I have shared is the chip DS28CN01 side schematics.

    According to A0, A1 pins, the address should be 0x2a, is it right?

    Ok, I will use i2c1.

    Thanks.

    Best Regards

    Zhong

  • I think the address will be 0x50 (7-bit) because AD0 and AD1 are grounded. Please cross-check once again. If you can run i2c probe on I2C1 it will tell you the exact address.

  • Renjith,

    Thanks for your replay.

    Yesterday I have run the i2c probe, and getting the address 0x18、0x68, do you mean that command was running on i2c0? If it is, how I can do to change from i2c0 to i2c1?

    Thanks.

    Best Regards

    Zhong

  • Renjith,

    You say my version of u-boot doesn't support i2c probe command,how should I do to make u-boot support i2c probe command?

    Thanks.

    Best Regards

    Zhong

  • Renjith,

    Now I can run the i2c1_mapper in ccs, the problem is that I did not choose the i2cclkenable on scripts.

    But now I meet a new problem, I can run the demo in ccs by choose i2cclkenable, if not in ccs, how  I should load i2cclkenable.

    Thanks.

    Best Regards

    Zhong

  • Zhong,

    Good to know that you are able to make progress. I would still recommend you to stick to u-boot or Linux as there is no much benefit in re-developing the I2C driver yourself. You can try to resolve the issue in accessing I2C device.