# I2C Pinmux and Capabilities

**URL:** <https://forum.amebaiot.com/t/i2c-pinmux-and-capabilities/1282>\
**Category:** Peripherals\
**Created:** [June 1, 2022, 10:25pm UTC](https://forum.amebaiot.com/t/i2c-pinmux-and-capabilities/1282 "2022-06-01T22:25:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Chiasson](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/michael_chiasson/32/1020_2.png) [@Michael\_Chiasson](https://forum.amebaiot.com/u/Michael_Chiasson)\
**Post date:** [June 1, 2022, 10:25pm UTC](https://forum.amebaiot.com/t/i2c-pinmux-and-capabilities/1282/1 "2022-06-01T22:25:28Z")

</div>

Hello,

I develop for the CEL CMP4010 which I understand to be based on the RTL8721CSM. I have run into some confusing things in the documentation and SDK.

UM-400 (Ameba-D User Manual v11) states in Table 6-1 Pad Types that the following pins can be used for I2C:

- PA[29], PA[30], PA[31]
- PB[0], PB[26], PB[27], PB[1], PB[2], PB[3]

However, all of the examples in the Realtek SDK use PA[25] and PA[26].

My questions:

1. Which is correct? Table 6-1 or examples or both?
2. Can a mix of ports be used? For example, PA[30] and PB[26]?
3. How is one pin specified as SDA vs SCL? i.e., `Pinmux_config` accepts a pin number and a pin function (PINMUX\_FUNCTION\_I2C) but I do not see anywhere to specify which pin is which. For example, if I wanted to use PA[30] as SCL and PB[26] as SDA, how do I specify that?

Thank you for any guidance you provide. Your help is very much appreciated.

Best,  
Michael

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [June 2, 2022, 3:00am UTC](https://forum.amebaiot.com/t/i2c-pinmux-and-capabilities/1282/2 "2022-06-02T03:00:33Z")

</div>

Hi, @Michael_Chiasson

This is my understanding of I2C on the RTL872x chip:

- There are two groups of I2C pins, corresponding to two hardware I2C peripherals
  - `I2C0`/`LP_I2C` group
    - SCL: PA\_25 / PA\_31 / PB\_5
    - SDA: PA\_26 / PB\_0 / PB\_6

  - `USI_I2C` group
    - SCL: PA\_23 / PB\_20 / PB\_24
    - SDA: PA\_24 / PB\_21 / PB\_25

- Within a group, you can choose one pin for SCL and one pin for SDA. Pins will not work across groups as they are physically connected to different I2C peripherals.
- The USI peripheral is a multi-function serial peripheral that can be configured for either I2C, SPI or UART, hence it has different code for using it as I2C.

You can refer to the [pinmux document](https://github.com/ambiot/ambd_sdk/tree/12dab4363fd0087eb4874461f8d3f6094110595f/doc/AmebaD) for the various pin functions.

For pin configuration, you can refer to the examples for configuration using [Mbed API](https://github.com/ambiot/ambd_sdk/tree/dev/project/realtek_amebaD_va0_example/example_sources/I2C/mbed) or [`Pinmux_config`](https://github.com/ambiot/ambd_sdk/tree/dev/project/realtek_amebaD_va0_example/example_sources/I2C/raw).  
For using the USI\_I2C peripheral, the [peripheral HAL header file](https://github.com/ambiot/ambd_sdk/blob/dev/component/soc/realtek/amebad/fwlib/include/rtl8721d_usi_i2c.h) shows how to use it.

---

<div class="post-metadata">

**Author:** ![Michael\_Chiasson](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/michael_chiasson/32/1020_2.png) [@Michael\_Chiasson](https://forum.amebaiot.com/u/Michael_Chiasson)\
**Post date:** [June 2, 2022, 3:56pm UTC](https://forum.amebaiot.com/t/i2c-pinmux-and-capabilities/1282/3 "2022-06-02T15:56:07Z")

</div>

Hey wyy,

Thank you for your response! I don’t know how I missed that Pinmux document; it explains clearly why my examples were not working with PA\_30 and PA\_26. Seems to me that Table 6-1 is completely irrelevant as none of the pins that can be used for I2C are included in the row that describes I2C.

I cannot use PA\_3, PB\_0, or USI because the 8721-based CMP4010 does not support the necessary pins, so I am forced use PA\_25 and PA\_26 (my application requires all ADC pins, so I can’t use PB\_5 or PB\_6). This is a let down because I also wanted to use USB but I2C is more important to my application.

Thank you again, wyy, for your help!

Michael
