
16. Inter Integrated Circuit (I2C)
MC97F6108A User’s manual
174
16.7.1
I2C block initialization process
After power ON, it is necessary to have to initialize I2C block for that I2C Block provide I2C Slave device
service
1.
I2C block will start operation (operation clock active) by setting IICEN bit on I2CMR register.
I2CMR = IICEN;
// I2C block enable
2.
Reset I2C block by setting RESET bit on I2CMR register.
I2CMR = RESET;
// Reset I2C block by S/W
3.
Depended on I2C devices, it shall define I2C SCL max clock and write the value of SCL Low
/High time and SDA hold time on I2CSCLLR, I2CSCLHR, I2CSDAHR as following diagram
SDA
SCL
I2CSCLLR
t
scll
I2CSCLHR
(t
sclh
)
I2CSDAHR
(t
sdah
)
The timing values are calculated as the follow formula
t
scll
=t
sysclk
( 4xI21 )
→
SCL clock low time
t
sclh
=t
sysclk
( 4xI23 )
→
SCL clock High time
t
sdah
=t
sysclk
( I24 )
→
SDA data hold time after falling edge of SCL
* t
sysclk
= system clock timing
Ex) In case of I2C clock (100kHz) and system clock (4MHz), each of t
scll,
t
sclh
times is 5us and
tsdah is 2.5 us.
I2CSCLLR = 5; I2CSCLHR = 4; I2CSDAHR = 6;
4.
It is to decide I2C Slave device address and write the address to I2CSAR.
I2CSAR = SELF_ADDRESS;
5.
Finally be ready to get I2C data from I2C bus system as slave device by setting I2C interrupt
enable, I2C block enable, ACK enable bits on I2CMR register.
I2CMR = IICEN+INTEN+ACKEN; // I2C interrupt enable