35.8.5.3.6 FIFO Operation
For better system bus utilization, the I2C embeds up to 16-bytes FIFO capability. The receive / transmit buffer is considered to have the FIFO mode enabled when the FIFOEN bit in CTRLC register is set (CTRLC.FIFOEN = 1). By default, the FIFO can act as a 16-by-8-bit array, or as a 4-by-32-bit array, depending on the setting of the CTRLC.DATA32B bit.
The hardware around this array implements four pointers, called the CPU Write Pointer (CPUWRPTR), the CPU Read Pointer (CPURDPTR), the I2C Write pointer (I2CWRPTR) and the I2C Read pointer (I2CRDPTR). All of these pointers reset to ‘0’. The CPUWRPTR and CPURDPTR pointers are native to the CPU clock domain, while the I2CWRPTR and I2CRDPTR are native to the I2C domain. The location pointed to by the CPUWRPTR is the current TX FIFO. The location pointed to by the CPURDPTR becomes the current RX FIFO. Writes to DATA register by the CPU will point to TX FIFO. Reads to DATA register by the CPU will point to RX FIFO. The location pointed to by the I2CWRPTR / I2CRDPTR is logically the current shift register.
When using the I2C configured as Host, the Address register must be written with the desired address (ADDR.ADDR), and optionally, the transaction Length and transaction Length Enable bits (ADDR.LEN and ADDR.LENEN) can be written if the 32-bit extension is enabled (CTRLC.DATA32B).
In client operation, the Address Match interrupt in the Interrupt Flag Status and Clear register (INTFLAG.AMATCH) is set after the address is received, and the SCL clock is stretched as long as the FIFO is empty in host read mode.
The FIFO threshold settings allow (CTRLC.TXTRHOLD, CTRLC.RXTRHOLD) allow flexible interrupt, DMA trigger and bus condition generations, as described below.
The FIFO is fully accessible if the SERCOM is halted, by writing the corresponding CPU FIFO pointer in the FIFOPTR register. The RX or TX FIFO can be individually cleared, by setting the respective FIFO Clear bit in the Control B register (CTRLB.FIFOCLR). The FIFO Clear must be written before data transfer begins. Writing the FIFO Clear bits while a frame is in progress will produce unpredictable results.
Hardware Actions in Host Mode
Direction | CTRLB.SMEN | CTRLC.DATA32B | LENGTH.LENEN | Action |
---|---|---|---|---|
Host Write | 0 | 0 | 0 |
|
0 | 1 | 0 | ||
0 | 1 | 1 |
| |
1 | 0 | 0 |
| |
1 | 1 | 0 | ||
1 | 1 | 1 | ||
Host Read | 0 | 0 | 0 |
|
0 | 1 | 0 | ||
0 | 1 | 1 | ||
1 | 0 | 0 | ||
1 | 1 | 0 | ||
1 | 1 | 1 |
Direction | CTRLB.SMEN | CTRLC.DATA32B | LENGTH.LENEN | Actions |
---|---|---|---|---|
Host Write | 0 | 0 | 0 |
|
0 | 1 | 0 | ||
0 | 1 | 1 |
| |
1 | 0 | 0 |
| |
1 | 1 | 0 |
| |
1 | 1 | 1 |
| |
Host Read | 0 | 0 | 0 |
|
0 | 1 | 0 |
| |
0 | 1 | 1 |
| |
1 | 0 | 0 |
| |
1 | 1 | 0 | ||
1 | 1 | 1 |
|
Hardware Actions in Client Mode
Direction | CTRLB.SMEN | CTRLC.DATA32B | LENGTH.LENEN | Condition |
---|---|---|---|---|
Host Write | 0 | 0 | 0 |
|
0 | 1 | 0 | ||
0 | 1 | 1 | ||
1 | 0 | 0 | ||
1 | 1 | 0 | ||
1 | 1 | 1 | ||
Host Read | 0 | 0 | 0 |
|
0 | 1 | 0 | ||
0 | 1 | 1 | ||
1 | 0 | 0 | ||
1 | 1 | 0 | ||
1 | 1 | 1 |
Direction | CTRLB.SMEN | CTRLC.DATA32B | LENGTH.LENEN | Actions |
---|---|---|---|---|
Host Write | 0 | 0 | 0 |
|
0 | 1 | 0 |
| |
0 | 1 | 1 |
| |
1 | 0 | 0 |
| |
1 | 1 | 0 |
| |
1 | 1 | 1 |
| |
Host Read | 0 | 0 | 0 |
|
0 | 1 | 0 |
| |
0 | 1 | 1 |
| |
1 | 0 | 0 |
| |
1 | 1 | 0 |
| |
1 | 1 | 1 |
|