GD32W51x User Manual
653
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 19-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
19.3.11.
Wakeup from Deep-sleep mode
When the address of I2C matches correctly, it can wake up from MCU Deep-sleep mode (APB
clock is off). In order to wake up from Deep-sleep mode, WUEN bit must be set in the
I2C_CTL0 register and the IRC16M must be selected as the clock source for I2CCLK. During
Deep-sleep
mode, the IRC16M is switched off. The I2C interface switches the IRC16M on,
and stretches SCL low until IRC16M is woken up when a START is detected. Then the
IRC16M is used as the clock of I2C to receive the address. When address matching is
detected, I2C stretches SCL during MCU wake-up. The SCL is released until the software
clears the ADDSEND flag and the transmission proceeds normally. If the detected address
does not match, IRC16M will be closed again and the MCU will not be wake up.
Only an address match interrupt (ADDMIE=1) can wakeup the MCU. If the clock source of
I2C is the system clock, or WUEN = 0, IRC16M will not switched on after receiving start signal.
When wakeup from Deep-sleep mode is enabled, the digital filter must be disabled and the
SS bit in I2C_CTL0 must be cleared. Before entering Deep-sleep mode (I2CEN=0), the I2C
peripheral must be disabled if wakeup from Deep-sleep mode is disabled (WUEN =0).
Note:
Only address match of I2C0 can wakeup MCU from Deep-sleep mode.
19.3.12.
Use DMA for data transfer
As is shown in I2C slave mode and I2C master mode, each time TI or RBNE is asserted,
software should write or read a byte, this may cause CPU
’
s high overload. The DMA controller
can be used to process TI and RBNE flag: each time TI or RBNE is asserted, DMA controller
does a read or write operation automatically.
The DMA transmission request is enabled by setting the DENT bit in I2C_CTL0 register. The
DMA reception request is enabled by setting the DENR bit in I2C_CTL0 register. In master
mode, the slave address, transmission direction, number of bytes and START bit are
programmed by software. The DMA must be initialized before setting the START bit. The
number of bytes to be transferred is configured in the BYTENUM[7:0] in I2C_CTL1 register.
In slave mode, the DMA must be initialized before the address match event or in the
ADDSEND interrupt routine, before clearing the ADDSEND flag.