Announcement

Collapse
No announcement yet.

I2C_Write()

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • I2C_Write()

    Hi,

    I've got some problems with the I2C_Write() documentation.

    The code:

    #platform "uLCD-32PTU"

    #inherit "4DGL_16bitColours.fnc"

    func main()

    var b:=0;

    I2C_Open(I2C_SLOW); // Open the I2C port in 100KHz mode
    I2C_Start(); //Send an I2C start condition.
    b:=I2C_Write(0);
    print("b= ",b); //prints: b= 2

    repeat
    forever

    endfunc

    There is nothing connected to the SDA/SCL - or any other pins.
    The I2C_Write(0); should fail.

    The Picaso 4dgl internal Functions Reference says under I2C_Write(byte);:
    "Returns Satus. Returns True if OK."

    Well, 'True
    ' is not a recognised keyword in this language.
    Also, generally, a non-zero value is considered to be true - this function returned '2' and obviously it is an error.

    Then the reference gives an example:
    "Status := I2C_Write(bytevalue);// Send a single byte to the I2C"

    Also generally speaking, such functions return a nonzero value indicating the status - which seems to be the case here.

    So, could we get a clarification on this? What does this function return and what does it mean?

    Thanks.

  • #2


    Generally in the documentation FALSE means 0 and TRUE means non 0.

    Returns

    0 : for fail (Generally write collision)
    1 : for success
    2 : for NAK from device (or device does not exist)

    We'll get the document updated
    Mark

    Comment

    Working...
    X