Problem i2c Red

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem i2c Red

425 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bruno on Tue Mar 20 13:52:53 MST 2012
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f](1) If it's a I2C write only, the number of bytes to be written is I2CWriteLength, I2CReadLength is zero, the content will be filled in the I2CMasterBuffer. [/COLOR][/SIZE]
[/COLOR][/SIZE](2) If it's a I2C read only, the number of bytes to be read is I2CReadLength, I2CWriteLength is 0, the read value will be filled in the I2CMasterBuffer. [/LEFT]


[LEFT]//Write[/LEFT]

[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* I2CWriteLength = 5 ;[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CReadLength = 0;[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CMasterBuffer[0] = PCF8594_ADDR;[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CMasterBuffer[1] = 0x03;[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CMasterBuffer[2] = 0x00;[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CMasterBuffer[3] = 0x00;[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CMasterBuffer[4] = 0x01;[/COLOR][/SIZE][/LEFT]
[SIZE=2][COLOR=#3f7f5f]I2CEngine(); */[/COLOR][/SIZE]

[SIZE=2][COLOR=#3f7f5f]// Read[/COLOR][/SIZE]
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][SIZE=2]I2CWriteLength = 0;[/SIZE][/SIZE][/COLOR][SIZE=2]
[SIZE=2][COLOR=#3f7f5f]I2CReadLength = 5;[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CMasterBuffer[0] = PCF8594_ADDR | RD_BIT;[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CMasterBuffer[1] = 0x03;[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CMasterBuffer[2];[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CMasterBuffer[3];[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]I2CMasterBuffer[4];[/COLOR][/SIZE][/LEFT]
[SIZE=2][COLOR=#3f7f5f]I2CEngine();[/COLOR][/SIZE]
[/SIZE][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE]
I'm not able to read the data correctly. Where is my logic wrong?
0 Kudos
Reply
7 Replies

386 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Wed Mar 21 11:57:06 MST 2012

Quote: stalisman

One of the greatest avoidable hardships is that of poor writing by  technical authors and other hired lackies of the of the chip producers  unwilling to pay for the production of decent documentation.


Thanks, I use to be one of those [I]lackies[/I] for about 10 years :eek:
We absolutely got no time to create any examples.


Quote:

It is as hard for an english speaking person to understand the poor  documentation written as it is for those whose first language is not  english.


Sorry, I must misunderstand what "documentation" means.
All I can find are some comments that show what the could could do ...

I had more than a bit of problems with the I2C driver.
Reason enough to create a version that is a bit more robust - unfortunately not taken over in the examples (yet). I've posted links to the driver in other posts - including short descriptions on how to use it - I'm not going to reproduce that right now since there is a big chance that I'm failing to mention something.

Regards,

Rob
0 Kudos
Reply

386 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by stalisman on Wed Mar 21 11:30:14 MST 2012

Quote: Zero
Are you kidding?

The text of i2ctest.c you have posted is describing #3:

And a few lines below this is shown in:

 
 /* Write SLA(W), address, SLA(R), and read one byte back. */
  I2CWriteLength = 2;
  I2CReadLength = 4;
  I2CMasterBuffer[0] = PCF8594_ADDR;
  I2CMasterBuffer[1] = 0x00;        /* address */
  I2CMasterBuffer[2] = PCF8594_ADDR | RD_BIT;
  I2CEngine();




You have to admit , in all fairness, that  the standard of english and  hence the logical meaning of the comments are rather poor. 

One of the greatest avoidable hardships is that of poor writing by  technical authors and other hired lackies of the of the chip producers  unwilling to pay for the production of decent documentation.

It is as hard for an english speaking person to understand the poor  documentation written as it is for those whose first language is not  english.

I think a sufficient answer to 'are you kidding' would have been 'prey,  in what world is this all obvious? .. for in mine the truth is wrapped  in gobldegook'.

Not exactly very informative but it does make one feel less stupid when insulted.
0 Kudos
Reply

386 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by stalisman on Wed Mar 21 11:28:09 MST 2012

Quote: Zero
Because Datasheet of PCF8594 is telling you what to do:




You have to admit , in all fairness, that  the standard of english and hence the logical meaning of the comments are rather poor. 

One of the greatest avoidable hardships is that of poor writing by technical authors and other hired lackies of the of the chip producers unwilling to pay for the production of decent documentation.

It is as hard for an english speaking person to understand the poor documentation written as it is for those whose first language is not english.

I think a sufficient answer to 'are you kidding' would have been 'prey, in what world is this all obvious? .. for in mine the truth is wrapped in gobldegook'.

Not exactly very informative but it does make one feel less stupid when insulted.
0 Kudos
Reply

386 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bruno on Wed Mar 21 07:35:11 MST 2012
Thanks Zero.

But actually discovered the problem the bit address is shifted by 1.

If I put the address 0x00 to read, he read 0x01. and so on
0 Kudos
Reply

386 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Mar 21 04:51:22 MST 2012

Quote: bruno
But the data just read is correct? Why can not I read the sign I just wrote!



Because Datasheet of PCF8594 is telling you what to do:


Quote:

Fig 7. Master reads PCF8594C-2 slave [COLOR=Red]after setting word address[/COLOR] (write word address; read data)

0 Kudos
Reply

386 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bruno on Wed Mar 21 04:31:26 MST 2012
But the data just read is correct? Why can not I read the sign I just wrote!
0 Kudos
Reply

386 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Mar 20 14:56:03 MST 2012

Quote:

Where is my logic wrong?

Are you kidding?

The text of i2ctest.c you have posted is describing #3:


Quote:

(3) If it's a I2C Write/Read with repeated start, specify the I2CWriteLength, fill the content of bytes to be written in I2CMasterBuffer, specify the I2CReadLength, after the repeated start and the device address with RD bit set, the content of the reading will be filled in I2CMasterBuffer index at I2CMasterBuffer[I2CWriteLength+2].

And a few lines below this is shown in:

 
 /* Write SLA(W), address, SLA(R), and read one byte back. */
  I2CWriteLength = 2;
  I2CReadLength = 4;
  I2CMasterBuffer[0] = PCF8594_ADDR;
  I2CMasterBuffer[1] = 0x00;        /* address */
  I2CMasterBuffer[2] = PCF8594_ADDR | RD_BIT;
  I2CEngine();
0 Kudos
Reply