6 years, 8 months ago.

How should I properly use same I2C on different lines?

Hello all,

I'm facing a problem while using same I2C on different lines (buses). Currently I'm using STM32L476VGT6.

Bug report:

Quote:

++ MbedOS Error Info ++ Error Status: 0x80FF0100 Code: 256 Module: 255 Error Message: riFatal Run-time error Location: 0x802281D Error Value: 0x0 Current Thread: Id: 0x200013CC Entry: 0x802BFC1 StackSize: 0x1000 StackMem: 0x20007AD8 SP: 0x20008A08 se For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80FF0100 MbedOS Error Info Device not detected!

I2C instances example

I2C i2c1(PB_7, PB_6);
I2C i2c2(PB_9, PB_8);

Are you using two identical i2c devices, i2c1 and i2c2 ? and the rest of the code?

I do not get an error with this on OS5 rev5350 on my board.

#include "mbed.h"

Serial pc(USBTX,USBRX);

I2C i2c1(PB_7, PB_6);
I2C i2c2(PB_9, PB_8);


int main()
{
    while(1);
}
posted by Paul Staron 25 Mar 2019

I was doing a little more research an created a simple project c/p below. However I don't know why I get search result on I2C only first time?

simple project

int main() {
    debug("start\n");

    debug("i2c1 init\n");
    debug("i2c1 search\n");
    I2C i2c1a(PB_7, PB_6);
    for (int address=0; address<256; address+=2) {
        if (!i2c1a.write(address, NULL, 0)) { // 0 returned is ok
            debug(" - I2C device found at address 0x%02X\n", address);
        }
    }
    debug("i2c2 init\n");
    I2C i2c1b(PB_9, PB_8);
    debug("i2c1 search\n");
    for (int address=0; address<256; address+=2) {
        if (!i2c1a.write(address, NULL, 0)) { // 0 returned is ok
            debug(" - I2C device found at address 0x%02X\n", address);
        }
    }
    debug("i2c2 search\n");
    for (int address=0; address<256; address+=2) {
        if (!i2c1b.write(address, NULL, 0)) { // 0 returned is ok
            debug(" - I2C device found at address 0x%02X\n", address);
        }
    }
    debug("end\n");
    return 0;
}
posted by Ozren Cecelja 26 Mar 2019
Be the first to answer this question.