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 peripheralPINCMx.INENA = 0: Disable the input pathPINCMx.PF = 0: No peripheral function selectedPINCMx.HIZ1 = 1: Enable High‑ZPINCMx.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 FIFOI2Cx.TFIFOCTL.TXFLUSH = 1: Flush TX FIFO
3) Enable Target mode
I2Cx.TCTR.ACTIVE = 1I2Cx.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 peripheralPINCMx.INENA = 1: Enable the input pathPINCMx.HIZ1 = 0: Disable High‑Z
5) Configure interrupts
I2Cx.ICLR (1048h / 1078h / 10A8h) = 1
Clear the required Target interrupt flagsI2Cx.IMASK (1028h / 1058h / 1088h) = 1
Enable only the required Target interruptsNVIC_ICPR[n] = 1: Clear pending interruptNVIC_ISER[n] = 1: Enable IRQ
Target ⇒ Hi‑Z
1) Wait for communication to stop
I2Cx.TSR.BUSBSY: I2C bus busy status0 = bus idle
2) Disable interrupts
I2Cx.IMASK (1028h / 1058h / 1088h) = 0
Mask Target interruptsI2Cx.ICLR (1048h / 1078h / 10A8h) = 1
Clear Target interrupt flagsNVIC_ICPR[n] = 1: Clear pending interruptNVIC_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 peripheralPINCMx.INENA = 0: Disable the input pathPINCMx.PF = 0: No peripheral function selectedPINCMx.HIZ1 = 1: Enable High‑ZPINCMx.PIPU/PIPD = 0: Disable internal pull-up / pull-down resistors
Best regard,
Ibuki Endo