I2C Pinmux and Capabilities

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

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 for the various pin functions.

For pin configuration, you can refer to the examples for configuration using Mbed API or Pinmux_config.
For using the USI_I2C peripheral, the peripheral HAL header file shows how to use it.

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

1 Like