15.3.7.5 Master Transmitter
To transmit data to a slave, the master must operate as a master transmitter.
Table 15.3 I2C Master Transmitter on page 408
the states the I
2
C module goes through while acting as a master transmitter. Every state where an interaction is required has the possi-
ble interactions listed, along with the result of the interactions. The table also shows which interrupt flags are set in the different states.
The interrupt flags enclosed in parenthesis may be set. If the BUSHOLD interrupt in I2Cn_IF is set, the module is waiting for an interac-
tion, and the bus is frozen. The value of I2Cn_STATE will be equal to the values given in the table when the BUSHOLD interrupt flag is
set, and can be used to determine which interaction is required to make the transmission continue.
The interrupt flag START in I2Cn_IF is set when the I
2
C module transmits the START.
A master operation is started by issuing a START command by setting START in I2Cn_CMD. ADDR+W, i.e., the address of the slave +
the R/W bit is then required by the I
2
C module. If this is not available in the transmit buffer, then the bus is held and the BUSHOLD
interrupt flag is set. The value of I2Cn_STATE will then be 0x57. As seen in the table, the I
2
C module also stops in this state if the
address is not available after a repeated start condition.
To continue, write a byte to I2Cn_TXDATA with the address of the slave in the 7 most significant bits and the least significant bit cleared
(ADDR+W). This address will then be transmitted, and the slave will reply with an ACK or a NACK. If no slave replies to the address,
the response will also be NACK. If the address was acknowledged, the master now has four choices. It can send data by placing it in
I2Cn_TXDATA/ I2Cn_TXDOUBLE (the master should check the TXBL interrupt flag before writing to the transmit buffer), this data is
then transmitted. The master can also stop the transmission by sending a STOP, it can send a repeated start by sending START, or it
can send a STOP and then a START as soon as possible. If the master wishes to make another transfer immediately after the current,
the preferred way is to start a new transfer directly by transmitting a repeated START instead of a STOP followed by a START. This is
so because if a STOP is sent out, then any master wishing to initiate a transfer on the bus can try to gain control of it.
If a NACK was received, the master has to issue a CONT command in addition to providing data in order to continue transmission. This
is not standard I
2
C, but is provided for flexibility. The rest of the options are similar to when an ACK was received.
If a new byte was transmitted, an ACK or NACK is received after the transmission of the byte, and the master has the same options as
for when the address was sent.
The master may lose arbitration at any time during transmission. In this case, the ARBLOST interrupt flag in I2Cn_IF is set. If the arbi-
tration was lost during the transfer of an address, and SLAVE in I2Cn_CTRL is set, the master then checks which address was trans-
mitted. If it was the address of the master, then the master goes to slave mode.
After a master has transmitted a START and won any arbitration, it owns the bus until it transmits a STOP. After a STOP, the bus is
released, and arbitration decides which bus master gains the bus next. The MSTOP interrupt flag in I2Cn_IF is set when a STOP condi-
tion is transmitted by the master.
Table 15.3. I2C Master Transmitter
I2Cn_STATE
Description
I2Cn_IF
Required in-
teraction
Response
0x57
Start transmitted
START interrupt flag
(BUSHOLD interrupt
flag)
ADDR+W ->
TXDATA
ADDR+W will be sent
STOP
STOP will be sent and bus released.
STOP +
START
STOP will be sent and bus released. Then a
START will be sent when bus becomes idle.
0x57
Repeated start trans-
mitted
START interrupt flag
(BUSHOLD interrupt
flag)
ADDR+W ->
TXDATA
ADDR+W will be sent
STOP
STOP will be sent and bus released.
STOP +
START
STOP will be sent and bus released. Then a
START will be sent when bus becomes idle.
-
ADDR+W transmitted
TXBL interrupt flag
(TXC interrupt flag)
None
EFM32JG1 Reference Manual
I2C - Inter-Integrated Circuit Interface
silabs.com
| Smart. Connected. Energy-friendly.
Preliminary Rev. 0.6 | 408