I2C write() bug in mbed r91?

07 Nov 2014

I believe there's a bug in the mbed library r91. I have been dealing with other unrelated I2C issues, but when creating new test apps, this bug sent me off on a tangent when trying to debug.

Using the following code, I can reproduce issues with r91 vs. r88.

#include "mbed.h"

I2C i2c(PTE25, PTE24); // sda, scl

int main()
{
    while( true) {
        // this block works with mbed r88, but does not with r91
        // r91 results in the address getting sent on the bus, but not the data
        char data[4] = { 'n', 0, 255, 0 };
        i2c.write( 0x12, data, 4);
        
        // this block works with mbed r88 and r91
        /*
        i2c.start();
        i2c.write( 0x12);
        i2c.write( 'n');
        i2c.write( 0);
        i2c.write( 255);
        i2c.write( 0);
        i2c.stop();
        */
    }
}

Running this as-is under r91, you'll see that only the address 0x12 is sent on the bus. Running this as-is under r88, you'll see that the address AND data are sent on the bus. I wish I could attach photos, but for whatever reason the file upload dialog doesn't seem to be working on this site.

Running the commented block of code instead, both revisions of the mbed library work.

07 Nov 2014

Guess mbed doesn't like Firefox.

Here's the bad trace using r91: /media/uploads/dmatsumoto/img_0894.jpg

Here's the good one with r88: /media/uploads/dmatsumoto/img_0895.jpg

07 Nov 2014

Thanks,

I was tearing my hair out this morning, wondering why my code wasn't working on a K64F. I switched back to r89 and all is right with the world...

...kevin