Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Stop Condition for I2C on U6

  • Please log in to reply
1 reply to this topic

#1 MarcoAndarcia

  • Members
  • 17 posts

Posted 01 April 2013 - 01:56 PM


I am working with the U6 and using the I2C C# implemantation. I got it to send the data bytes to communicate with my PCF8575,
I manage to read the ACKS from my slave device( PCF8575); however the values on the ports are not changing, and I believe is because I need to implement an stop condition

this is how my code looks:
byte[] write_array = new byte[2];
			  write_array[0] = (byte)0;
			  write_array[1] = (byte)0;
			  double numI2CBytesToWrite = 2;

			  LJUD.AddRequest(_U6.ljhandle, LJUD.IO.PUT_CONFIG, LJUD.CHANNEL.I2C_ADDRESS_BYTE, 0x40, 0, 0);
			  LJUD.AddRequest(_U6.ljhandle, LJUD.IO.I2C_COMMUNICATION, LJUD.CHANNEL.I2C_WRITE,numI2CBytesToWrite,write_array,0);
			  LJUD.AddRequest(_U6.ljhandle, LJUD.IO.I2C_COMMUNICATION, LJUD.CHANNEL.I2C_GET_ACKS, 0, 0, 0);

			  LJUD.GetResult(_U6.ljhandle, LJUD.IO.I2C_COMMUNICATION, LJUD.CHANNEL.I2C_WRITE, ref dummyDouble);
			  txbreceive.Text += "# ofBytes sent: "+ dummyDouble.ToString() + "\r\n";
			  LJUD.GetResult(_U6.ljhandle, LJUD.IO.I2C_COMMUNICATION, LJUD.CHANNEL.I2C_GET_ACKS, ref writeacks);
			  txbreceive.Text += "Received ACKS: " + writeacks.ToString() + "\r\n";
			  expectedacks = Math.Pow(2, numI2CBytesToWrite + 1) - 1;
			  txbreceive.Text += "Expected ACKS: " + expectedacks.ToString() + "\r\n";

Right now the expected ACKS match the received ACKS. but I think I need to send an stop condition do the slave transfers the data from the register to the actual ports. On the example for the C# implemantation they mention the stop condition, but they don't show it.

PS: I manage to read from my device (and it was very simple, again it doesn't require an stop condition to read).


#2 MarcoAndarcia

  • Members
  • 17 posts

Posted 01 April 2013 - 03:28 PM

Actually fixed the problem. The I2C output expander started to work after restarted, without using an stop condition.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users