ITC pin numbers

Working libraries, libraries being ported and related hardware
Post Reply
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

ITC pin numbers

Post by mebab »

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
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: ITC pin numbers

Post by fpiSTM »

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();
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: ITC pin numbers

Post by mebab »

Great!
I just moved two pin-definitions above Wire.begin() and it worked.

Thanks a lot!
Post Reply

Return to “Libraries & Hardware”