To initialize the I2C controller, perform the following steps:
- Configure the I2C_CON register:
- For controller or target mode, set the
I2C_CON[10] MST bit (0: target; 1:
controller).
- For transmitter or receiver mode, set the
I2C_CON[9] TRX bit (0: receiver; 1:
transmitter).
- If using an interrupt to transmit and receive
data, set the corresponding bit in the
I2C_IRQENABLE_SET register to 1 (the
I2C_IRQENABLE_SET [4] XRDY_IE bit for the transmit
interrupt, the I2C_IRQENABLE_SET [3] RRDY bit for
the receive interrupt).