Module Setup in I2C/SMBus Mode

The I3C Target module can be set up to operate in I2C mode by following the recommended order of settings shown in Table 1 below. An example setup code is shown in Module Setup in I2C/SMBus Mode below.

CAUTION: The I3C Target module will only be set up in I2C mode when the device is connected to an I2C bus with an I2C Controller. If an I3C Controller is present on the bus and broadcasts an ENTDAA CCC on the bus, the Target module will participate in the Dynamic Address Assignment process and switch to operating in I3C mode (OPMD = 0b01).
Table 1. Recommended Module Setup Order for I3C® Mode Operation
Setting Description Section Reference
Module Clock Select the appropriate clock for the I3C module using I3CxCLK register I3C Module Clock
Bus Time-out (for SMBus mode) Enable the bus time-out feature using BTOEN bit in I3CxCON register. The bus time-out threshold and duration can be set using I3CxBTO and I3CxBRST registers. The SMBus specification requires a bus time-out threshold of 25 ms Bus Time-out Reset
Static Address Set the desired static address for the I3C module using I3CxSADR register I2C Static Address
Buffers and FIFO The CLRRXB and CLRTXB bits in the I3CxCON register can be used to clear the receive and transmit buffers and FIFO immediately after the I3C module is enabled Transmit and Receive Buffers
Interrupts Clear all the module-level and system-level interrupt flags. Enable the desired interrupts by setting the appropriate interrupt enable bits. Remember to enable the system-level interrupt controller to generate the enabled interrupts. Interrupts and DMA Triggers
Buffer Selection Select the appropriate buffer (I2C/SMBus Buffer) using the RxyI2C register (IOLVCON register is ignored). Enable the 50 ns spike filters and select the appropriate SDA hold time using I3CxI2CCON register SDA and SCL Pins
Module Enable Enable the I3C module in the end by setting the EN bit in the I3CxCON register

Module Setup in I2C/SMBus Mode

void I3C1_Target_I2CSetup()
{
    // Select Clock
    I3C1CLK = 0x00;         // Fosc/4=1MHz

    // Bus Time-out settings (for SMBus, optional)
    I3C1CONbits.BTOEN = 1;  // Enable Bus Timeout
    I3C1BTO = 25000;        // 25 ms
    I3C1BRST = 15;          // Bus time-out Reset duration

    // Static Address
    I3C1SADR = 0x30;        // Static Address

    // Clear buffers and FIFOs
    I3C1CONbits.CLRRXB = 1; // Clears I3C1RXB Rx Buffer and Rx FIFO
    I3C1CONbits.CLRTXB = 1; // Clears I3C1TXB Tx Buffer and Tx FIFO

    // Clear all interrupt flags
    I3C1PIR0 = 0x00;        // Module-level general interrupts
    I3C1PIR1 = 0x00;
    I3C1ERRIR0 = 0x00;      // Module-level error interrupts
    I3C1ERRIR1 = 0x00;
    PIRxbits.I3C1IF = 0;    // System-level general interrupt
    PIRxbits.I3C1EIF = 0;   // System-level error interrupt
    PIRxbits.I3C1TXIF = 0;  // System-level transmit interrupt
    PIRxbits.I3C1RXIF = 0;  // System-level receive interrupt
    PIRxbits.I3C1RIF = 0;   // System-level reset interrupt

    // Enable interrupts as needed
    I3C1PIE0 = 0x00;
    I3C1PIE1 = 0x00;
    I3C1ERRIE0 = 0x00;
    I3C1ERRIE1 = 0x00;
    PIExbits.I3C1IE = 0;  
    PIExbits.I3C1EIE = 0;   
    PIExbits.I3C1TXIE = 0;  
    PIExbits.I3C1RXIE = 0;  
    PIExbits.I3C1RIE = 0;  

    // Select I2C/SMBus Buffer
    I3C1I2CCONbits.FLTEN = 1;     // Enable spike filters
    I3C1I2CCONbits.SDAHT = 0b01;  // Select appropriate SDA Hold Time
    RC0I2Cbits.TH = 0b01;         // Select appropriate I2C/SMBus buffers on I3C1_SCL pin
    RC0I2Cbits.PU = 0b01;         // Select appropriate pull ups on I3C1_SCL pin
    RC0I2Cbits.SLEW = 0b01;       // Select appropriate slew rate on I3C1_SCL pin
    RC1I2Cbits.TH = 0b01;         // Select appropriate I2C/SMBus buffers on I3C1_SDA pin
    RC1I2Cbits.PU = 0b01;         // Select appropriate pull ups on I3C1_SDA pin
    RC1I2Cbits.SLEW = 0b01;       // Select appropriate slew rate on I3C1_SDA pin

    // Enable Target Module
    I3C1CONbits.EN = 1;     // Also disables TTL buffers on SDA/SCL pads
}