16 I2C (I2C)16-4 Seiko Epson Corporation S1C31D41 TECHNICAL MANUAL(Rev. 1.1)Baud rate generator clock output and operations for supporting clock stretchingFigure 16.3.3.1 shows the clock generated by the baud rate generator and the clock waveform on the I2C bus.SCLO (internal signal)SCLn (external pin)SCL rising/falling periodClock stretching period by another I2 C deviceBaud rate generator counting suspended periodBaud rate generator counting periodPeriod in which the internal and external statuses are not matchedFigure 16.3.3.1 Baud Rate Generator Output Clock and SCLn Output WaveformThe baud rate generator output clock SCLO is compared with the SCLn pin status and the results are returnedto the baud rate generator. If a mismatch has occurred between SCLO and SCLn pin levels, the baud rate gen-erator suspends counting. This extends the clock to control data transfer during the SCL signal rising/fallingperiod and clock stretching period in which SCL is fixed at low by a slave device.16.4 Operations16.4.1 InitializationThe I2C Ch.n should be initialized with the procedure shown below.When using the I2C in master mode1. Configure the operating clock and the baud rate generator using the I2C_nCLK and I2C_nBR registers.2. Assign the I2C Ch.n input/output function to the ports. (Refer to the “I/O Ports” chapter.)3. Set the following bits when using the interrupt:- Write 1 to the interrupt flags in the I2C_nINTF register. (Clear interrupt flags)- Set the interrupt enable bits in the I2C_nINTE register to 1. (Enable interrupts)4. Set the following I2C_nCTL register bits:- Set the I2C_nCTL.MST bit to 1. (Set master mode)- Set the I2C_nCTL.SFTRST bit to 1. (Execute software reset)- Set the I2C_nCTL.MODEN bit to 1. (Enable I2C Ch.n operations)When using the I2C in slave mode1. Set the following I2C_nMOD register bits:- I2C_nMOD.OADR10 bit (Set 10/7-bit address mode)- I2C_nMOD.GCEN bit (Enable response to general call address)2. Set its own address to the I2C_nOADR.OADR[9:0] (or OADR[6:0]) bits.3. Assign the I2C Ch.n input/output function to the ports. (Refer to the “I/O Ports” chapter.)4. Set the following bits when using the interrupt:- Write 1 to the interrupt flags in the I2C_nINTF register. (Clear interrupt flags)- Set the interrupt enable bits in the I2C_nINTE register to 1. (Enable interrupts)5. Set the following I2C_nCTL register bits:- Set the I2C_nCTL.MST bit to 0. (Set slave mode)- Set the I2C_nCTL.SFTRST bit to 1. (Execute software reset)- Set the I2C_nCTL.MODEN bit to 1. (Enable I2C Ch.n operations)