epikao
July 12, 2022, 2:32pm
1
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
pylon
July 12, 2022, 4:04pm
2
epikao:
How can I do this?
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);
epikao:
How can I do this?
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.
epikao
July 13, 2022, 8:47am
4
Thank you very much, that helps :-). I am not yet so familiar with objects, classes, pointers.
sterretje:
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.
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....
system
Closed
January 9, 2023, 8:47am
5
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.