
CH32V003
Reference Manual
V1.3
150
13.10 Packet error checking
Packet Error Checksum (PEC) is an additional CRC8 checksum step to provide transmission reliability,
calculated for each bit of serial data using the following polynomial.
C=X
8
+X
2
+X+1
The PEC calculation is activated by the ENPEC bit in the control register and is performed on all information
bytes, including address and read/write bits. In transmitting, enabling PEC adds a byte of CRC8 calculation
result after the last byte of data; while in receiving mode, in the last byte is considered as CRC8 check result,
and if it does not match with the internal calculation result, it will reply a NAK, and in case of the main receiver,
regardless of the correct check result.
13.11 Register description
Table 13-1 I2C-related registers list
Name
Offset address
Description
Reset value
R16_I2C_CTLR1
0x40005400
I2C control register 1
0x0000
R16_I2C_CTLR2
0x40005404
I2C control register 2
0x0000
R16_I2C_OADDR1
0x40005408
I2C
address register 1
0x0000
R16_I2C_OADDR2
0x4000540C
I2C
address register 2
0x0000
R16_I2C_DATAR
0x40005410
I2C
data register
0x0000
R16_I2C_STAR1
0x40005414
I2C
status register 1
0x0000
R16_I2C_STAR2
0x40005418
I2C
status register 2
0x0000
R16_I2C_CKCFGR
0x4000541C
I2C
clock register
0x0000
13.11.1 I2C Control register 1(I2C1_CTLR1)
Offset address: 0x00
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
SWR
ST
Reserved
PEC POS ACK STOP STAR
T
NOS
TRET
CH
ENG
C
ENPE
C
Reserved
PE
Bit
Name
Access
Description
Reset value
15
SWRST
RW
Software reset, setting this bit by user code will
reset the I2C peripheral. Make sure the pins of the
I2C bus are released and the bus is idle before the
reset.
Note: This bit resets the I2C module when no stop
condition is detected on the bus but the busy bit is
1.
0
[14:13] Reserved
RO
Reserved
0
12
PEC
RW
Packet error checking bit, set this bit to enable
packet error detection. The user code can set or
clear this bit; the hardware clears this bit when the
PEC is transmitted, when a start or end signal is
generated, or when the PE bit is cleared to 0.
1: With PEC.
0: Without PEC.
Note: The PEC is invalidated when arbitration is
lost.
0
11
POS
RW
ACK and PEC position setting bits, which can be
set or cleared by user code and can be cleared by
0