
16. Inter Integrated Circuit (I2C)
MC97F6108A User’s manual
176
16.7.3
Master transmitter
Main software is to have write/read data to/from slave I2C device. The software has to be ready to get
number of data with internal RAM or sending data on internal RAM according to I2C bus protocol type
of Slave device. It writes Salve Address to I2CDR register in I2C Block and then if it set START bit on
I2CMR register I2C block send slave address with SCL clock to slave device. I2C Block takes master
mode (MASTER bit -> 1) and take the read/write state (TMODE bit, read(0), write(1)) according to the
data direction bit (R/
W̅
) of device address.
The following is examples software for the case of master mode
Master Write
I2CMR = IICEN+INTEN; // set I2C block( enable IIC block, I2C interrupt)
I2CDR = Slave A Write mode; // load target Salve Address
I2CMR |= SRT;
// generate start condition and send slave address
I2C Interrupt Service
If(Master Mode) and (TMODE)
If( ACK and GCALL or ACK and TEND )
If ( Not End of Data )
I2CDR = NEXT DATA;
// load target Salve Address
I2CSR = 0xFF;
// Byte transmit start
ELSE
I2CMR = IICEN+INTEN+STP; // STOP generation
ELSE
Initialize I2C block
// if have ACK error, any error
End of I2C interrupt service