Go Down

Topic: Wire.endTransmission(); (Read 341 times) previous topic - next topic

encryptor

How do I know whether this function returns a TRUE or FALSE? 

Quote
As of Arduino 1.0.1, endTransmission() accepts a boolean argument changing its behavior for compatibility with certain I2C devices.

If true, endTransmission() sends a stop message after transmission, releasing the I2C bus.

If false, endTransmission() sends a restart message after transmission. The bus will not be released, which prevents another master device from transmitting between messages. This allows one master device to send multiple transmissions while in control.

The default value is true.


I'm using it in this piece of code from the Li Power Shield example code.  I imagine that only 1 line of code using Wire.write(); is necessary, right?
Code: [Select]
/************************************************************************
5. i2cWrite16(unsigned int data, unsigned char address) writes 16 bits
   of data beginning at an 8-bit address, and continuing to the next.
************************************************************************/
void i2cWrite16(unsigned int data, unsigned char address)
{

  Wire.beginTransmission(MAX17043_ADDRESS);
  Wire.write(address);
  //Wire.write((byte)((data >> 8) & 0x00FF));                 
  //Wire.write((byte)(data & 0x00FF));
  Wire.endTransmission();
}
peace*&^

PaulS

Quote
How do I know whether this function returns a TRUE or FALSE? 

The optional argument has nothing to do with whether the function returns true or false. The documentation is talking about what endTransmission(true); does that is different from what endTransmission(false); does.

PaulS

Quote
I imagine that only 1 line of code using Wire.write(); is necessary, right?

Is it address or data that you want to send? Doesn't the I2C device you are talking to know it's address? If not, how does it know you are talking to it?

If it does know it's address, what use is it sending the low order byte of the address to it?

encryptor

#3
Jan 01, 2013, 10:16 pm Last Edit: Jan 01, 2013, 10:42 pm by encryptor Reason: 1

Quote
I imagine that only 1 line of code using Wire.write(); is necessary, right?

Is it address or data that you want to send? Doesn't the I2C device you are talking to know it's address? If not, how does it know you are talking to it?

If it does know it's address, what use is it sending the low order byte of the address to it?


I believe it is both data and address I want to send.  I did not create this function, but its purpose is to Configure the MAX17043's alert percentage.  I understand the Li Power shield to be the Master and the Arduino Uno R3 to be the slave.  I don't know if the i2c device I'm talking to knows its address.  How do I find out?  I assume the i2c device that I'm talking to is the Arduino Uno R3.

I'm calling this function with this data - i2cWrite16(0x9700, 0x0C);
peace*&^

Go Up