Hey everyone. Sorry if that topic was somwhere before but i didn`t found that.
I`ve got a microcontroller STM32f103C8T6 and i had successfully installed library for programming that with arduino IDE help. And in my project i need to use more than 1 i2c port and i know that my board got 2 ports i2c, (that link to pinout immage of my board) https://os.mbed.com/media/uploads/hudakz/stm32f103c8t6_pinout_voltage01.png
But i can
t find the information about how to switch between i2c1 and i2c2. for example im used example from LCD I2C “hello world” and it automaticly choosed PB6 and PB7 like I2C ports but i’m want to use PB11 and PB10… tell me please how i can switch that.
I’m adding the code from that example maybe it will help :
LiquidCrystal_I2C lcd(0x27, 16, 2);
While the IDE may work for your microcontroller, no all libraries are going to be 100% compatible. The Wire library, for example, uses hardware definitions from twi.h/twi.c which may lack a definition for your board. Therefore, you will need to write a modified twi.c for your hardware, and define twi_h so you do not have conflicts, as well you may want to instantiate a second TwoWire object as only one is instantiated in the wire library. As for switching, that depends on how you implement the objects and would need more information and code from your project. Have you got wire.h working on one of the busses?
You could try here: [SOLVED] Using multiple I2C - Arduino for STM32
It is not clear if this solution is applicable only to a specific version of the STM32 Arduino core, though.
Just to be clear, why do you need two I2C busses?
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.