Dynamic IC_TAR or IC_10BITADDR_MASTER Update
The I
2C controller 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:
The I
2C controller is not enabled (IC_ENABLE=0);
The I
2C controller is enabled (IC_ENABLE=1); AND I2C controller is NOT engaged in any Master (TX,
RX) operation (IC_STATUS[5]=0); AND I
2C controller is enabled to operate in Master mode
(IC_CON[0]=1); AND there are no entries in the TX FIFO (IC_STATUS[2]=1)
Master Transmit and Master Receive
The I
2C controller 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
2C Rx/Tx Data Buffer and Command Register
(IC_DATA_CMD). The CMD bit [8] should be written to 0 for I
2C 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.
Disabling the I2C Controller
The register IC_ENABLE_STATUS is added to allow software to unambiguously determine when the
hardware has completely shutdown in response to the IC_ENABLE register being set from 1 to 0.
1. Define a timer interval (ti2c_poll) equal to the 10 times the signaling period for the highest I
2C
transfer speed used in the system and supported by the I
2C controller. For example, if the highest I2C
transfer mode is 400 Kbps, then ti2c_poll is 25 us.
2. Define a maximum time-out parameter, MAX_T_POLL_COUNT, such that if any repeated polling
operation exceeds this maximum value, an error is reported.
3. Execute a blocking thread/process/function that prevents any further I
2C master transactions to be started
by software, but allows any pending transfers to be completed.
This step can be ignored if the I
2C controller is programmed to operate as an I2C slave only.
4. The variable POLL_COUNT is initialized to zero.
5. Set IC_ENABLE to 0.
6. Read the IC_ENABLE_STATUS register and test the IC_EN bit (bit 0). Increment POLL_COUNT by
one. If POLL_COUNT >= MAX_T_POLL_COUNT, exit with the relevant error code.
7. If IC_ENABLE_STATUS[0] is 1, then sleep for ti2c_poll and proceed to the previous step.
Otherwise, exit with a relevant success code.
DMA Controller Operation
To enable the DMA controller interface on the I
2C controller, you must write the DMA Control Register
(IC_DMA_CR). Writing a 1 to the TDMAE bit field of IC_DMA_CR register enables the I
2C controller transmit
handshaking interface. Writing a 1 to the RDMAE bit field of the IC_DMA_CR register enables the I
2C
controller receive handshaking interface.
The FIFO buffer depth (FIFO_DEPTH) for both the RX and TX buffers in the I
2C controller is 64 entries.
Altera Corporation
I2C Controller
20-17
Dynamic IC_TAR or IC_10BITADDR_MASTER Update
cv_54020
2013.12.30