GD32A50x User Manual
531
must be set. In order to check the PEC byte, it is necessary to clear the RELOAD bit and set
PECTRANS bit. After receiving BYTENUM-1 data, the next received byte will be compared
with the data in the I2C_PEC register. If the PEC values does not match, the NACK is
automatically generated. If the PEC values matches, the ACK is automatically generated,
regardless of the NACKEN bit value. When PEC byte is received, it is also copied into the
I2C_RDATA register, and RBNE flag will be set. If the ERRIE bit in I2C_CTL0 register is 1,
when PEC value does not match, the PECERR flag will be set and the interrupt will be
generated. If ACK control is not required, then PECTRANS can be set to 1 and BYTENUM
can be programmed according to the number of bytes to be received.
Note:
After the RELOAD bit is set, the PECTRANS cannot be changed.
Figure 20-22. SMBus Master Transmitter and Slave Receiver communication flow
Start Slave address
ACK
DATA0
ACK
DATA N-1
ACK
Stop
……
data transfer (N+1 bytes)
From master to slave
From slave to master
W(0)
PEC
ACK
SMBus Master Receiver and Slave Transmitter
If the SMBus master is required to receive PEC at the end of bytes transfer, automatic end
mode can be enabled. Before sending a START signal on the bus, PECTRANS bit must be
set and slave addresses must be programmed. After receiving BYTENUM-1 data, the next
received byte will be compared with the data in the I2C_PEC register automatically. A NACK
is respond to the PEC byte before STOP signal.
If the SMBus master receiver is required to generate a RESTART signal after receiving PEC
byte, the software mode (AUTOEND = 0) must be selected. Before sending a START signal
to the bus, PECTRANS bit must be set and slave addresses must be programmed. After
receiving BYTENUM-1 data, the next received byte will be compared with the contents of the
I2C_PEC register automatically. The TC flag will be set after PEC is sent, then the SCL line
is stretched low. The RESTART can be set in the TC interrupt routine.
When used as slave transmitter, in order to allow PEC transmission at the end of
BYTENUM[7:0] bytes, SBCTL must be set. If PECTRANS bit is set, the number of bytes in
BYTENUM[7:0] contains PEC byte. In this case, if the number of bytes requested by the
master is greater than BYTENUM-1, the total number of TI interrupts will be BYTENUM-1,
and the contents of the I2C_PEC register will be transmitted automatically.
Note:
After the RELOAD bit is set, the PECTRANS cannot be changed.
Figure 20-23. SMBus Master Receiver and Slave Transmitter communication flow
Start
Slave address
R(1)
ACK
Stop
……
data transfer (N+1 bytes)
From master to slave
From slave to master
DATA0
ACK
DATA N-1
ACK
PEC
NACK