Inter-integrated Circuit (I2C) Interface
User Manual All information provided in this document is subject to legal disclaimers. © REALTEK 2019. All rights reserved.
257
example, the I
2
C slave continues to send data to the remote master as long as the remote master is acknowledging the data sent and there is
data available in the Tx FIFO. There is no need to hold the SCL line low or to issue RD_REQ again.
If the remote master is to receive
n
bytes from the I
2
C but the programmer wrote a number of bytes larger than
n
to the Tx FIFO, then when
the slave finishes sending the requested
n
bytes, it clears the Tx FIFO and ignores any excess bytes.
13.2.8.2
Master Mode Operation
This section discusses master mode procedures.
13.2.8.2.1
Initial Configuration
The target address and address format can be changed dynamically without having to disable I
2
C. This parameter only applies to when I
2
C is
acting as a master because the slave requires the component to be disabled before any changes can be made to the address.
The procedures are very similar and are only different with regard to where the IC_10BITADDR_MASTER bit is set (bit 12 of IC_TAR register).
(1)
Disable the I
2
C by writing 0 to the IC_ENABLE register.
(2)
Write to the IC_CON register to set the maximum speed mode supported for slave operation (bits 2:1). Writing 1 to bit 0 and bit 6 to
enable Master Module and disable Slave Module.
(3)
Write to the IC_TAR register the address of the I
2
C device to be addressed. It also indicates whether a General Call or a START BYTE
command is going to be performed by I
2
C. The desired speed of the I
2
C master-initiated transfers, either 7-bit or 10-bit addressing, is
controlled by the IC_10BITADDR_MASTER bit field (bit 12).
(4)
Enable the I
2
C by writing a ‘1’ in the IC_ENABLE register.
(5)
Now write transfer direction and data to be sent to the IC_DATA_CMD register. If the IC_DATA_CMD register is written before the I
2
C is
enabled, the data and commands are lost as the buffers are kept cleared when I
2
C is disabled.
13.2.8.2.2
Dynamic IC_TAR or IC_10BITADDR_MASTER Update
The I
2
C supports dynamic updating of the IC_TAR (bits 9:0) and IC_10BITADDR_MASTER (bit 12) bit fields of the IC_TAR register. You can
dynamically write to the IC_TAR register provided the following conditions are met:
(1)
I
2
C is not enabled (IC_ENABLE=0); OR
(2)
I
2
C is enabled (IC_ENABLE=1); AND
I
2
C is NOT engaged in any Master (tx, rx) operation (IC_STATUS[5]=0); AND
I
2
C is enabled to operate in Master mode (IC_CON[0]=1); AND
there are NO entries in the Tx FIFO (IC_STATUS[2]=1)
13.2.8.2.3
Master Transmit and Master Receive
The I
2
C supports switching back and forth between reading and writing dynamically. To transmit data, write the data to be written to the lower
byte of the I
2
C Rx/Tx Data Buffer and Command Register (IC_DATA_CMD). The bit 8 (
CMD
) should be written to 0 for I
2
C write operations.
Subsequently, a read command may be issued by writing “don’t cares” to the lower byte of the IC_DATA_CMD register, and a 1 should be
written to the CMD bit. The I
2
C master continues to initiate transfers as long as there are commands present in the transmit FIFO. If the STOP
bit set 1, the I
2
C inserts a STOP condition after completing the current transfer.
13.2.9
IC_CLK Frequency Configuration
When the I
2
C is configured as a master, the *CNT registers must be set before any I
2
C bus transaction can take place in order to ensure proper
I/O timing. The *CNT registers are:
IC_SS_SCL_HCNT
IC_SS_SCL_LCNT
IC_FS_SCL_HCNT
IC_FS_SCL_LCNT
IC_HS_SCL_HCNT
IC_HS_SCL_LCNT
The document authorized to
SZ99iot
2019-05-15 10:08:03