Very welcome. Good luck!
On Mar 25, 2014 10:28 AM, "Santiago Alfaro" <[email protected]> wrote:
> YES!!!
>
> not only that works but it got me much closer to answering some of my long
> lingering questions about I2C. I can't keep working on this project until
> next week so I might bug you again. but for now, thanks so much.
>
> On Friday, March 21, 2014 5:03:49 PM UTC-4, Ytai wrote:
>>
>> Forgive me, I had originally misinterpreted what you're trying to do.
>> The TWI interface only allows responses of size 254 or less.
>>
>> The good news is the you don't really need to dump the entire EEPROM if
>> all you need is a small subset.
>>
>> You probably want something like:
>>
>> bool readEeprom(int start_address, byte[] result) {
>> byte request[] = new byte[] { (byte) start_address };
>> return twi_.writeRead(0x50, false, request, 1, result, result.length);
>> }
>>
>> Then, you can call for example:
>> byte[] result = new byte[2];
>> if (readEeprom(247, result)) {
>> // result[0] now contains the value in EEPROM address 247
>> // result[1] now contains the value in EEPROM address 248
>> }
>>
>> etc...
>>
>> If you need to dump the entire thing, just do two transactions of 128
>> bytes or so.
>>
>> Similarly, you can write a simple writeEeprom() function for calibration.
>> This would be a write-only operation (i.e. response is null and response
>> size is 0), where the start_address sites the first byte of the request
>> buffer, followed by the contents to be written starting at this address.
>>
>>
>> On Fri, Mar 21, 2014 at 1:23 PM, Santiago Alfaro <[email protected]>wrote:
>>
>>> Hi,
>>>
>>> yes I have pull-ups to the 3.3 coming from the ioio and I have the
>>> sensor on a separate source at 2.6 with all grounds connected.
>>>
>>> so what you mean is I should do this...
>>>
>>> *try {*
>>> * Log.d(TAG, ":| Trying to read");*
>>> * if (port.writeRead(address, false,
>>> request,request.length,response,response.length)){*
>>> * Log.i(TAG, ":) Got Initial response"); *
>>> * for(int i=0; i<response.length; i++){*
>>> * Log.i(TAG, "EEPROM Dump "+i+" = "+ response[i]);*
>>> * if(i == 0xf7){*
>>> * Log.i(TAG, "Triming Value = "+ response[i]);*
>>> * }*
>>> * }*
>>> * }else{*
>>> * Log.i(TAG, ":( NO response"); *
>>> * }*
>>>
>>>
>>> ... right? But then again I have the problem that when *response.length
>>> = 255*, I get "*:( NO response"* but when *response.length = 120* I get
>>> a bunch of numbers but not the one I need which is 247. I'm not sure if
>>> that is part of the problem, but I'm curious since I don't know yet why
>>> that happens.
>>>
>>>
>>> On Thursday, March 20, 2014 8:12:44 PM UTC-4, Ytai wrote:
>>>
>>>> The writeRead() function returns a boolean that will be false in case
>>>> anything goes wrong (for example, failing to get an ACK from the device).
>>>> The contents of the response array do not matter, only its size.
>>>> Do you have pull-ups on SDA and SCL?
>>>>
>>>>
>>>> On Thu, Mar 20, 2014 at 2:29 PM, Santiago Alfaro <[email protected]>wrote:
>>>>
>>>>> Here is where I keep getting into trouble.
>>>>>
>>>>> I've tried with 0x00 meaning that
>>>>>
>>>>> byte[] request = new byte[] { 0x00 }; //Byte address to ask for
>>>>> sensor data
>>>>>
>>>>> but that gives me an EEPROM dump of 0 and I know that is not right.
>>>>>
>>>>> I added the "0x50" on the request byte because I figured I was doing
>>>>> something wrong and on the Datasheet it shows that EEPROM Dump has the
>>>>> Slave Address and a Write, then the command (0x00) and then the
>>>>> slaveaddress (again) and a Read so since just 0x00 was not working I tried
>>>>> that and won't work either.
>>>>>
>>>>> How do I check for the return value of writeRead? won't that be the
>>>>> actual EEPROM Dump that I get with the for loop?
>>>>>
>>>>> also, in the arduino code I can use this line i2c_start_wait(0xA0);
>>>>> which Issues a start condition and sends address and transfer
>>>>> direction. If device is busy, use ack polling to wait until device is
>>>>> ready is there a way to do this with the ioio?
>>>>>
>>>>> Lastly, in playing with variables and trying things I realized that if
>>>>> I have the response byte be { 0xFF } my EEPROM dump will be all 0. But if
>>>>> I
>>>>> change the response Byte to { 0x7F } then I get a bunch of numbers. I
>>>>> don't
>>>>> understand why the length of the response byte changes the values of the
>>>>> response.
>>>>>
>>>>> Thanks
>>>>> Santiago
>>>>>
>>>>>
>>>>> On Wednesday, March 19, 2014 5:58:11 PM UTC-4, Ytai wrote:
>>>>>
>>>>>> You only need your twi write to be one byte long (0x00).
>>>>>> Also make sure to check the return value of writeRead
>>>>>> On Mar 19, 2014 2:29 PM, "Santiago Alfaro" <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>> Hello All
>>>>>>>
>>>>>>> I'm starting to get a handle on TWI on the ioio but I have not been
>>>>>>> able to get an EEPROM dump from this sensor.
>>>>>>>
>>>>>>> The datasheet for the sensor can be found here
>>>>>>> http://www.melexis.com/MLX90620
>>>>>>>
>>>>>>> and what I think are the relevant parts of it are these:
>>>>>>>
>>>>>>>
>>>>>>> <https://lh4.googleusercontent.com/-DQO16I0bc_8/UyoLocosLAI/AAAAAAAAFU4/Df0qFbs20Xo/s1600/EEPROM.png>
>>>>>>>
>>>>>>> and
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> <https://lh4.googleusercontent.com/-D2PP5yuAifY/UyoKBahwBOI/AAAAAAAAFUs/5NfmDToaRdc/s1600/ExportWholeEEPROM.png>
>>>>>>>
>>>>>>>
>>>>>>> The code I have so far is this:
>>>>>>>
>>>>>>>
>>>>>>> * twiEeprom = ioio_.openTwiMaster(0, TwiMaster.Rate.RATE_400KHz,
>>>>>>> false); *
>>>>>>>
>>>>>>> * ...*
>>>>>>>
>>>>>>> * ReadEeprom(0x50, twiEeprom);*
>>>>>>>
>>>>>>> * ...*
>>>>>>>
>>>>>>> * public void ReadEeprom(int address, TwiMaster port) {*
>>>>>>>
>>>>>>> * byte[] request = new byte[] { 0x00, 0x50 }; //Byte address to ask
>>>>>>> for sensor data*
>>>>>>>
>>>>>>> * byte[] response = new byte[ 0xFF ]; //Byte to save sensor data*
>>>>>>>
>>>>>>> * try {*
>>>>>>>
>>>>>>> * Log.d(TAG, ":| Trying to read");*
>>>>>>>
>>>>>>> * port.writeRead(address, false,
>>>>>>> request,request.length,response,response.length);*
>>>>>>>
>>>>>>> * for(int i=0; i<response.length; i++){*
>>>>>>>
>>>>>>> * Log.i(TAG, "EEPROM Dump "+i+" = "+ response[i]);*
>>>>>>>
>>>>>>> * }*
>>>>>>>
>>>>>>> * Log.d(TAG, ":) success reading");*
>>>>>>>
>>>>>>> * ...*
>>>>>>>
>>>>>>> My problem is that I keep getting all zeros on the EEPROM Dump. I
>>>>>>> know I'm correctly connected because it works on an Arduino. (also
>>>>>>> because
>>>>>>> I already burnt a IOIO trying to figure another thing out :D but now the
>>>>>>> new one is surviving )
>>>>>>>
>>>>>>>
>>>>>>> Is there anything that jumps out that I'm doing wrong? I can send
>>>>>>> more detail if needed.
>>>>>>>
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Santiago
>>>>>>>
>>>>>>> --
>>>>>>> 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 http://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 http://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 http://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 http://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 http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.