Hi Ytai,

You are right, I can do it in one writeRead() call. As I did below:

byte[] request=new byte[]{0x01}; //data that I want to write
byte[] response = new byte[1];


In setup()( function:


i2c=ioio_.openTwiMaster(2, TwiMaster.Rate.RATE_100KHz, false);


In loop() function:


if(i2c.writeRead(0x63, false, request, request.length, response, 
response.length)) //This call returns true 
{
   pw.print(String.format("%02X", response[0]));
   pw.print(" ");
}


However, my problem still remains. The data (0x01) in request interpreted 
as starting address of read. Therefore, I read the default data in the 
register which has the address 0x01. However, I would like to write 0x01 as 
(data) into the first register of device and read it back.

What might am I doing wrong ? Is there a way to log/dump writeRead() call ?

Thank you in advance.
Regards,


On Wednesday, February 10, 2016 at 4:23:30 PM UTC+1, Ytai wrote:
>
> Why are you separating this into two transactions? It is very uncommon.
> On Feb 10, 2016 5:09 AM, "Lumi" <[email protected] <javascript:>> wrote:
>
>> Hello
>>
>> I found a figure (attached) explaining how the communication should take 
>> place, I believe this helps to clarify the issue.
>>
>> Thanks.
>>
>> On Wednesday, February 10, 2016 at 12:33:25 PM UTC+1, Lumi wrote:
>>>
>>> Dear all,
>>>
>>> I am trying to talk with an external device via ioio-otg twi ports. I 
>>> would like to write and read data to/from the registers of my external 
>>> device.
>>>
>>> Here are samples from my code:
>>>
>>> byte[] request=new byte[]{0x01}; //data that I want to write
>>> byte[] response = new byte[13];
>>>
>>>
>>> In setup()( function:
>>>
>>>
>>> i2c=ioio_.openTwiMaster(2, TwiMaster.Rate.RATE_100KHz, false);
>>>
>>>
>>> In loop() function:
>>>
>>>
>>> if(i2c.writeRead(0x63, false, request, request.length, null, 0)) { //Here, 
>>> I only want to write 
>>>
>>> if (i2c.writeRead(0x63, false, null, 0, response, response.length))// Here, 
>>> I only want to read
>>> {
>>>    for (int i = 0; i < 13; i++) {
>>>       pw.print(String.format("%02X", response[i]));
>>>       pw.print(" ");
>>>    }
>>>
>>> }
>>>
>>>
>>> Both writeRead() functions return true.
>>>
>>> However, the data 0x01 in request array is interpreted as an internal 
>>> address of a register in the device. I could not get 0x01 interpreted as 
>>> data and written into external device register.
>>>
>>>
>>> This may not be very clear, but maybe there are some people who can already 
>>> spot the problem.
>>>
>>>
>>> Thank you in advance,
>>>
>>> Regards.
>>>
>>>
>>>
>> On Wednesday, February 10, 2016 at 12:33:25 PM UTC+1, Lumi wrote:
>>>
>>> Dear all,
>>>
>>> I am trying to talk with an external device via ioio-otg twi ports. I 
>>> would like to write and read data to/from the registers of my external 
>>> device.
>>>
>>> Here are samples from my code:
>>>
>>> byte[] request=new byte[]{0x01}; //data that I want to write
>>> byte[] response = new byte[13];
>>>
>>>
>>> In setup()( function:
>>>
>>>
>>> i2c=ioio_.openTwiMaster(2, TwiMaster.Rate.RATE_100KHz, false);
>>>
>>>
>>> In loop() function:
>>>
>>>
>>> if(i2c.writeRead(0x63, false, request, request.length, null, 0)) { //Here, 
>>> I only want to write 
>>>
>>> if (i2c.writeRead(0x63, false, null, 0, response, response.length))// Here, 
>>> I only want to read
>>> {
>>>    for (int i = 0; i < 13; i++) {
>>>       pw.print(String.format("%02X", response[i]));
>>>       pw.print(" ");
>>>    }
>>>
>>> }
>>>
>>>
>>> Both writeRead() functions return true.
>>>
>>> However, the data 0x01 in request array is interpreted as an internal 
>>> address of a register in the device. I could not get 0x01 interpreted as 
>>> data and written into external device register.
>>>
>>>
>>> This may not be very clear, but maybe there are some people who can already 
>>> spot the problem.
>>>
>>>
>>> Thank you in advance,
>>>
>>> Regards.
>>>
>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "ioio-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/ioio-users.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to