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.

omap3 i2c speed / method

Other Parts Discussed in Thread: OMAP3530

I do have a question regarding I2C. I am using Omap3530 and access several I2C devices.

It is working but terrible slow. For a write and read back it will take around 0.5ms. Kernel is configured for 400kHz

I build a kernel driver and did there

 

    i2cdev3=i2c_get_adapter(3); // aquire interface

and uses this routines:

.int i2cw8(struct i2c_adapter *dev,unsigned char i2cadr,unsigned char addr,unsigned char dat)
{
    int ret_val;
    if (down_interruptible(&mutex))
        ;

    msg->addr=i2cadr;
    msg->flags=0;
    msg->len=2;                //number of bytes + 1
    msg->buf=data;
    data[0]=addr;
    data[1]=dat;
    ret_val=i2c_transfer(dev,msg,1);
     up(&mutex);
     return 0;
}

unsigned char i2cr8(struct i2c_adapter *dev,unsigned char i2cadr,unsigned char addr)
{
    unsigned char ret_val;
    if (down_interruptible(&mutex))
        ;

    msg[0].addr=i2cadr;
    msg[0].flags=0;
    msg[0].len=1;                //just the address
    msg[0].buf=data;
    data[0]=addr;

    msg[1].addr=i2cadr;
    msg[1].flags=I2C_M_RD;
    msg[1].len=1;                //number of bytes
    msg[1].buf=data;
   
    i2c_transfer(dev,msg,2);
    ret_val = data[0];
    up(&mutex);
    return ret_val;
}

Is there a better/faster way ?

Best regards

Arno

  • Hi Arno,

    I wouldn't say faster, but you can try profiling i2c_smbus_write/write_byte/word_data() api. Also if your slave device supports higher speed you can try configuring to higher frequency, which you can do through boot args (i2c_bus=bus_id,clkrate).

    Thanks,

    Vaibhav

  • Thanks for hints. I will check this. More than 400kHz bus speed is not supported by my devices.

    BTW: How to handle this, if more than one application running on OMAP wants to access I2C? Is this possible and how? In my current solution (see first post) it is not working. I can't open the driver only once. What method would be best?

    Best regards

    Arno