Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Due] (I2C) Wire.endTransmission always returns non-zero. #1251

Closed
chriskner opened this issue Jan 28, 2013 · 6 comments
Closed

[Due] (I2C) Wire.endTransmission always returns non-zero. #1251

chriskner opened this issue Jan 28, 2013 · 6 comments
Assignees
Labels
Board: Arduino Due Applies only to the Due Library: Wire The Wire Arduino library
Milestone

Comments

@chriskner
Copy link

1.5.1r2

It looks like endTransmission returns the number of bytes sent from the transmit buffer, not an indication of success, as http://arduino.cc/en/Reference/WireEndTransmission suggests.

from \arduino-1.5.1r2\hardware\arduino\sam\system\libsam\source\twi.c :

uint8_t TwoWire::endTransmission(uint8_t sendStop) {
    ...
    while (sent < txBufferLength) {
        ...
    }
    ...
    return sent;
}
@nathanhere
Copy link

I also just tested the return value of endTransmission, and it definitely has a bug. I tried sending 5 bytes over I2C, and it returned the number 5. This is only supposed to return a value of 0 - 4.

@lestofante
Copy link

The bug is in the lib or in the reference?
Il giorno 31/gen/2013 23:11, "Nathan" notifications@github.com ha scritto:

I also just tested the return value of endTransmission, and it definitely
has a bug. I tried sending 5 bytes over I2C, and it returned the number 5.
This is only supposed to return a value of 0 - 4.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1251#issuecomment-12968881.

@chriskner
Copy link
Author

Unfortunately, the more you dig, the worse it gets.

It appears to me the devs at one point realized the work ahead of them was not trivial, and decided to supply a base-line functionality (below current standards). This is not a meant as a dig, just reality.

Any proc in the Wire library that accesses the I2C status register has been, or needs to be neutered (which is why I believe endTransmission got mangled in this version). Basically, any marginally serious I2C communication must bypass this version of the library, and twiddle the MCU registers directly.

Just scan the datasheet and look for bits that are "clear[ed] on read". This is totally not handled properly in 1.5.1r2.

@chriskner chriskner reopened this Jan 31, 2013
@leszekru
Copy link

does not work in 1.5.2...
Is there a software i2c lib that works on Due???

@zelfkoelman
Copy link

Any news on this topic? I'm totally stuck in getting a PCA9622 Led driver to work over i2c... The Arduino gets stuck in the endTransmission function.

@sandeepmistry
Copy link
Contributor

The return code has been addressed by @bluesign2k's commit e079baa and is already in master.

@ffissore ffissore modified the milestone: Release 1.6.6 Oct 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Board: Arduino Due Applies only to the Due Library: Wire The Wire Arduino library
Projects
None yet
Development

No branches or pull requests

8 participants