[Armadillo:05427] Armadillo I2C communication problem

Dimitris Tsiougkos email@hidden
2010年 7月 14日 (水) 00:01:33 JST

Hello to everyone,

I am new user of the Armadillo 500 embedded platform and I am very happy
with this extremely powerful development board.
I am writing a small piece of code using the I2C interface and a problem
occurs when I am trying to write and read with the ioctl_rdrw. My code is

int main(int argc, char **argv)
  struct i2c_rdwr_ioctl_data rdwr_msg;
  unsigned int i2fd;
  unsigned short addr;
  int ret;

   char output[] = {0x2, 0x1, 0x1};
   char input[10] = {0};
   addr = 0x18;

  fd = open("/dev/i2c-0", O_RDWR);

  if (!i2cfd) {
  printf("Error on opening the device file\n");
  return 0;

  rdwr_msg.nmsgs = 2;

  rdwr_msg.msgs = (struct i2c_msg*)malloc(rdwr_msg.nmsgs*sizeof(struct
  if (!rdwr_msg.msgs) {
   printf("Memory alloc error\n");
   return 0;

        (rdwr_msg.msgs[1]).len = 4;
     (rdwr_msg.msgs[1]).addr  = start_address;
     (rdwr_msg.msgs[1]).flags = I2C_M_RD;
     (rdwr_msg.msgs[1]).buf = &input[0];

     rdwr_msg.msgs[0].len   = 3;
     (rdwr_msg.msgs[0]).addr  = start_address;
     (rdwr_msg.msgs[0]).flags = 0;
     (rdwr_msg.msgs[0]).buf = &output[0];

  ioctl(fd,I2C_TIMEOUT,3);  /* set the timeout    */
  ioctl(fd,I2C_RETRIES,1);  /* set the retries    */

  ret = ioctl(fd,I2C_RDWR, &rdwr_msg);

  if ( ret < 0 ) {
  printf("Error during I2C_RDWR ioctl with error code: %d\n",ret);



As you can see the code is quite simple. I can write but when a read
transaction is called, a failure is caused.

I also used the SMSbus transactions since the i2c-dev driver supports these
But the problem remains. I put some printk in the driver code (mxc_i2c.c)
and an arbitration lost occurs.
To be more specific, I want to communicate with a device (in address 0x18)
which receives a command like 0x2 0x1 0x1 and sends a response
like 0x3 0x1 0x0 0x1. The problem is in master reception when the SDA
remains high and the SCL is LOW. Form the I2C spec, the arbitration is lost.

Could you please help this situation?

Thank you for your time.

Take care

Dpl Ing. Dimitris Tsiougkos
-------------- next part --------------
URL: <http://lists.atmark-techno.com/pipermail/armadillo/attachments/20100713/ea485842/attachment.html>

armadillo メーリングリストの案内