This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSPM0G1507: About the I2C Target Mode Switching Method

Part Number: MSPM0G1507

Hi expert,

Regarding the switching of the I2C Target mode
from Disabled (port High‑Z) to Enabled (I2C Target with interrupts), and
from Enabled (I2C Target with interrupts) back to Disabled (port High‑Z):

Would you please confirm whether the following register operation procedures are appropriate for each transition?

During the switching process:

  • The SCL/SDA ports are kept in the High‑Z state, and
  • For the I2C peripheral, any pending or unexpected interrupts are cleared so that the device is in a clean state after the transition.

1) Configure the I2C pins while keeping the ports in High‑Z

  • PINCMx.PC = 0 : Disconnect the peripheral
  • PINCMx.INENA = 0 : Disable the input path
  • PINCMx.PF = 0 : No peripheral function selected
  • PINCMx.HIZ1 = 1 : Enable High‑Z
  • PINCMx.PIPU/PIPD = 0 : Disable internal pull-up / pull-down resistors

2) Pre‑processing before enabling I2C Target mode (recommended)

  • I2Cx.TFIFOCTL.RXFLUSH = 1 : Flush RX FIFO
  • I2Cx.TFIFOCTL.TXFLUSH = 1 : Flush TX FIFO

3) Enable Target mode

  • I2Cx.TCTR.ACTIVE = 1
  • I2Cx.TOAR.OAR = xx : Configure the Target own address

4) Connect SCL/SDA to the I2C peripheral

  • PINCMx.PF = xxh <PF value for I2C_SCL or I2C_SDA>
  • PINCMx.PC = 1 : Connect the peripheral
  • PINCMx.INENA = 1 : Enable the input path
  • PINCMx.HIZ1 = 0 : Disable High‑Z

5) Configure interrupts

  • I2Cx.ICLR (1048h / 1078h / 10A8h) = 1
    Clear the required Target interrupt flags
  • I2Cx.IMASK (1028h / 1058h / 1088h) = 1
    Enable only the required Target interrupts
  • NVIC_ICPR[n] = 1 : Clear pending interrupt
  • NVIC_ISER[n] = 1 : Enable IRQ

Target ⇒ Hi‑Z

1) Wait for communication to stop

  • I2Cx.TSR.BUSBSY : I2C bus busy status
    0 = bus idle

2) Disable interrupts

  • I2Cx.IMASK (1028h / 1058h / 1088h) = 0
    Mask Target interrupts
  • I2Cx.ICLR (1048h / 1078h / 10A8h) = 1
    Clear Target interrupt flags
  • NVIC_ICPR[n] = 1 : Clear pending interrupt
  • NVIC_ICER[n] = 1 : Disable IRQ

3) Disable Target mode

  • I2Cx.TCTR.ACTIVE = 0

4) Force SCL/SDA to High‑Z

  • PINCMx.PC = 0 : Disconnect the peripheral
  • PINCMx.INENA = 0 : Disable the input path
  • PINCMx.PF = 0 : No peripheral function selected
  • PINCMx.HIZ1 = 1 : Enable High‑Z
  • PINCMx.PIPU/PIPD = 0 : Disable internal pull-up / pull-down resistors

Best regard,

Ibuki Endo

  • 1) Configure the I2C pins while keeping the ports in High‑

    I think below code is can be removed

    • PINCMx.INENA = 0 : Disable the input path  (because the input mode is also hiz, it not affect the signal outside)
    • PINCMx.PIPU/PIPD = 0 : Disable internal pull-up / pull-down resistors  (For I2C normally have external pull up so it is not need to enable/disable the internal pull up resistor)

    Let me know if you have any issue with the operation flow above?

**Attention** This is a public forum