Hi,
I want to use PC0 (I2C3_SCL) and PC1 (I2C3_SDA) in an STM32 board for communication to an external RTC with the 'Wire' library. It seems that neither of the following definitions don't work:
Code: Select all
Wire.begin();
#define SCL PC0
#define SDA PC1
or
Code: Select all
Wire.begin();
Wire.setSCL(PC0);
Wire.setSDA(PC1);
Is there a simple way to define new pins?
Thanks in advance.
by fpiSTM » Thu May 06, 2021 12:48 pm
First which board you used ?
Then read the wiki carefully:
https://github.com/stm32duino/wiki/wiki ... tance-pins
Change default Wire instance pins
It is also possible to change the default pins used by the Wire instance using above API:
Code: Select all
void setSCL(uint32_t scl)
void setSDA(uint32_t sda)
void setSCL(PinName scl)
void setSDA(PinName sda)
Have to be called before begin().
Example:
Code: Select all
Wire.setSDA(PC_4); // using pin name PY_n
Wire.setSCL(PC2); // using pin number PYn
Wire.begin();
Go to full post