I2C Multimaster Peripheral
2.8
Programming Guidelines
2.8.1
Main Program
Module Configuration Before Enabling the Module
Initialization Procedure
Configure Slave Address and Data Counter Registers
Initiate a Transfer
Poll Receive Data
88
Serial Interfaces
Step 1: Program the prescaler to obtain an approximately 12-MHz I
ule clock (I2C_PSC = x; this value is to be calculated and is depen-
dent on the system clock frequency).
Step 2: Program the I
= x and I2C_SCLH = x; these values are to be calculated and are de-
pendent on the system clock frequency).
Step 3: Configure its own address (I2C_OA = x).
2
Step 4: Take the I
C module out of reset (I2C_CON:I2C_EN = 1).
Step 1: Configure the I
Step 2: If using interrupt for transmit/receive data, enable interrupt masks
(I2C_IE).
Step 3: If using DMA for transmit/receive data, enable the DMA (I2C_BUF)
and program the DMA controller.
In master mode, configure the slave address (I2C_SA = x) and the number of
bytes associated with the transfer (I2C_CNT = x).
Poll the bus busy (BB) bit in the I
to 0 (bus not busy), configure START/STOP (I2C_CON:STT / I2C_CON:STP)
condition to initiate a transfer.
Poll the receive data ready interrupt flag bit (RRDY) in the I
(I2C_STAT). Use the RRDY interrupt or the DMA to read the receive data in
the data receive register (I2C_DATA).
2
C clock to obtain 100K bps or 400K bps (I2C_SCLL
2
C mode register (I2C_CON) bits.
2
C status register (I2C_STAT). If it is cleared
2
C mod-
2
C status register
SPRU760B