of
IC_RAW_INTR_STAT
that return bit 5 (
R_RD_REQ
) set to 1 must be treated as the equivalent of the
RD_REQ
interrupt referred to in this section.†
The
RD_REQ
interrupt is raised upon a read request, and like interrupts, must be cleared when exiting the
interrupt service handling routine (ISR). The ISR allows you to either write 1 byte or more than 1 byte into
the TX FIFO. During the transmission of these bytes to the master, if the master acknowledges the last byte
then the slave must raise the
RD_REQ
again because the master is requesting for more data. †
If the programmer knows in advance that the remote master is requesting a packet of n bytes, then when
another master addresses the I
2
C controller and requests data, the TX FIFO could be written with n number
bytes and the remote master receives it as a continuous stream of data. For example, the I
2
C controller 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 issue
RD_REQ
again. †
If the remote master is to receive n bytes from the I
2
C controller 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. †
The I
2
C controller generates a transmit abort (
TX_ABRT
) event to indicate the clearing of the TX FIFO in
this example. At the time an ACK/NACK is expected, if a NACK is received, then the remote master has all
the data it wants. At this time, a flag is raised within the slave's state machine to clear the leftover data in the
TX FIFO. This flag is transferred to the processor bus clock domain where the FIFO exists and the contents
of the TX FIFO are cleared at that time. †
Master Mode Operation
Initial Configuration
For master mode operation, the target address and address format can be changed dynamically without
having to disable the I
2
C controller. This feature is only applicable when the I
2
C controller is acting as a
master because the slave requires the component to be disabled before any changes can be made to the
address. To use the I
2
C controller as a master, perform the following steps: †
For multiple I2C transfers, perform additional writes to the Tx FIFO such that the Tx FIFO does not become
empty during the I2C transaction. IF the Tx FIFO is completely emptied at any stage, then the master stalls
the transfer by holding the SCL line low because there was no stop bit indicating the master to issue a STOP.
The master will complete the transfer when it finds a Tx FIFO entry tagged with a Stop bit.†
1. Disable the I
2
C controller 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)
and to specify whether the I
2
C controller starts its transfers in 7/10 bit addressing mode when the device
is a slave (bit 3). †
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
controller 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 controller by writing a 1 in the
IC_ENABLE
register. †
5. Now write the 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 controller is enabled, the data and commands are lost as the buffers are
kept cleared when the I
2
C controller is not enabled. †
I2C Controller
Altera Corporation
cv_54020
Master Mode Operation
20-16
2013.12.30