Skip to content

Wire library does not send stop condition when receiving as a master on MSP430 eUSCI module #119

Open
@llozi

Description

@llozi

I unsuccessfully tried to use the Wire library on an MSP430FR5969 launchpad using the eUSCI_B0 module to communicate to a MPR121 touch controller (eUSCI_B0 in I2C mode uses pins 14 and 15 on launchpad (ports 1.7, 1.6))
So I connected the logic analyzer an could observe, that when calling

Wire.beginTransmission(slaveaddr);
Wire.write(MPR121_CONFIG1);
Wire.endTransmission(false); // repeated start
Wire.requestFrom(slaveaddr, 1, true);

the expected data is transferred but no stop condition is set by requestFrom and the master continues to clock the bus.

I could fix this issue by adding a few lines to msp430-lg-core/libraries/Wire/utility/twi.c,
the diff is:

592,596d591
<     if ((sendStop) && (length > 0)) {
<       UCBzCTLW1 |= UCASTP_2;                // do generate Stop after last Byte to send
<     } else {
<       UCBzCTLW1 &= ~UCASTP_2;               // do not generate Stop
<     }

As I'm not an expert with the eUSCI module and I2C, i'm not sure whether this is an appropriate patch.
Interestingly no reference to the sendStop argument at all appears in the twi_readFrom function (besides the call to the SW I2C implementation).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions