[Armadillo:05438] Re: Armadillo I2C communication problem

Keishiro Tabe email@hidden
2010年 7月 15日 (木) 11:46:53 JST


Hi, Dimitris


First, you should try the following.

#define SLAVE_ADDRESS		0x18
fd = open("/dev/i2c-0", O_RDWR);
if( ioctl(fd, I2C_SLAVE, SLAVE_ADDRESS) < 0 ) {
    printf("address error\n");
}

I2C slave address is "AAAAAAAX".
  A: slave address : 7bit (MSB First).
  X: R/W Flag


Next,
I think that you want to perform "read after write" procedure.
You should use "struct i2c_rdwr_ioctl_data".

+	struct i2c_rdwr_ioctl_data rdwr = {
+	  .msgs = &rdwr_msg,
+	  .nmsgs = 2,
+	};

	(rdwr_msg.msgs[1]).len = 4;
-	(rdwr_msg.msgs[1]).addr  = start_address;
+	(rdwr_msg.msgs[1]).addr  = SLAVE_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[1]).addr  = start_address;
+	(rdwr_msg.msgs[0]).addr  = SLAVE_ADDRESS;
	(rdwr_msg.msgs[0]).flags = 0;
	(rdwr_msg.msgs[0]).buf = &output[0];

-	ret = ioctl(fd,I2C_RDWR, &rdwr_msg);
+	ret = ioctl(fd,I2C_RDWR, &rdwr);


Hope this helps,

tabe


(2010/07/15 0:48), Dimitris Tsiougkos wrote:
> Hello Yashi,
> 
> 
> Thank you very much for the response
> 
> I have the armadillo board acting as a master and I want to communicate with
> another board(audio sensor STM32 ARM) acting as slave.
> 
> The slave (audio) device is the 0x18 and this cannot be changed. So, I
> configure in master's side the slave address to 0x18. Of course I can change
> the value via ioctl, but I can't access the slave's device.
> The first time I send a data_block using the i2c_smbus_write_block(), the
> reception is ok but after this procedure
> I can not read or write. The clock line is low and the SDA remains high.
> According to the protocol, this is a clock stretching phenomenon and
> everithing stops working. Every write or read I execute, an error is
> returned back. I also checked the mxc_i2c.c file to understand the procedure
> of transmission and reception. I observed a right first data trans. but
> after that a kernel message of "Bus arbitration lost" was rising.
> 
> Thanks in advance,
> 
> Dimitris
> 
> 
> 2010/7/14 Yasushi SHOJI<email@hidden>
> 
>> At Tue, 13 Jul 2010 08:01:33 -0700,
>> Dimitris Tsiougkos wrote:
>>>
>>> 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.
>>
>> is it possible to change the device address from 0x18 to something
>> else?  in other words, does any of i2c device react on the address
>> 0x18?
>> --
>>           yashi
>>
>> _______________________________________________
>> armadillo mailing list
>> email@hidden
>> http://lists.atmark-techno.com/cgi-bin/mailman/listinfo/armadillo
>>
> 
> 
> 
> 
> 
> _______________________________________________
> armadillo mailing list
> email@hidden
> http://lists.atmark-techno.com/cgi-bin/mailman/listinfo/armadillo



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