FRAM_I2C library, how to change I2C device/pins?

Hello

I am using the following FRAM_I2C library (which use the Wire library) and have a question about how to change the default I2C device/pins there.

My MCU has two I2C available, see below:
TwoWire Wire1(I2C1, PB7, PB6);
TwoWire Wire2(I2C2, PB11, PB10);

The FRAM library uses the standard I2C1, but I want to switch to the I2C2.

How can I do this?

Thanks for any hint

By providing the corresponding Wire object to the constructor of the library.

So, instead of

FRAM fram;

you use

TwoWire Wire2(I2C2, PB11, PB10);
FRAM fram(&Wire2);

Out of curiosity, why do you want to do that? If your MCU has to act as both a master and a slave, it makes sense, else not so much.

Thank you very much, that helps :-). I am not yet so familiar with objects, classes, pointers.

Yes, that's right, i2c can operate multiple devices. However, I have now connected it to the second i2c and just wanted to know how I can handle it....

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.