User manual

...the world's most energy friendly microcontrollers
2012-04-24 - Giant Gecko Family - d0053_Rev0.96 424
www.energymicro.com
I2Cn_STATEDescription I2Cn_IF Required
interaction
Response
START Repeated start condition will be sent
STOP +
START
STOP will be sent and the bus released. Then
a START will be sent when the bus becomes
idle
- Data transmitted TXBL interrupt flag
(TXC interrupt flag)
None
TXDATA DATA will be sent
STOP STOP will be sent. Bus will be released
START Repeated start condition will be sent
0xD7 Data transmitted,ACK
received
ACK interrupt flag
(BUSHOLD interrupt
flag)
STOP +
START
STOP will be sent and the bus released. Then
a START will be sent when the bus becomes
idle
CONT +
TXDATA
DATA will be sent
STOP STOP will be sent. Bus will be released
START Repeated start condition will be sent
0xDF Data
transmitted,NACK
received
NACK(BUSHOLD
interrupt flag)
STOP +
START
STOP will be sent and the bus released. Then
a START will be sent when the bus becomes
idle
None - Stop transmitted MSTOP interrupt flag
START START will be sent when bus becomes idle
None - Arbitration lost ARBLOST interrupt
flag
START START will be sent when bus becomes idle
16.3.7.5 Master Receiver
To receive data from a slave, the master must operate as a master receiver, see Table 16.5 (p. 425) .
This is done by transmitting ADDR+R as the address byte instead of ADDR+W, which is transmitted to
become a master transmitter. The address byte loaded into the data register thus has to contain the 7-
bit slave address in the 7 most significant bits of the byte, and have the least significant bit set.
When the address has been transmitted, the master receives an ACK or a NACK. If an ACK is received,
the ACK interrupt flag in I2Cn_IF is set, and if space is available in the receive shift register, reception
of a byte from the slave begins. If the receive buffer and shift register is full however, the bus is held
until data is read from the receive buffer or another interaction is made. Note that the STOP and START
interactions have a higher priority than the data-available interaction, so if a STOP or START command
is pending, the highest priority interaction will be performed, and data will not be received from the slave.
If a NACK was received, the CONT command in I2Cn_CMD has to be issued in order to continue
receiving data, even if there is space available in the receive buffer and/or shift register.
After a data byte has been received the master must ACK or NACK the received byte. If an ACK is
pending or AUTOACK in I2Cn_CTRL is set, an ACK is sent automatically and reception continues if
space is available in the receive buffer.
If a NACK is sent, the CONT command must be used in order to continue transmission. If an ACK
or NACK is issued along with a START or STOP or both, then the ACK/NACK is transmitted and the
reception is ended. If START in I2Cn_CMD is set alone, a repeated start condition is transmitted after
the ACK/NACK. If STOP in I2Cn_CMD is set, a stop condition is sent regardless of whether START is
set. If START is set in this case, it is set as pending.