www
.mcu.com.cn
183
/
239
Rev.
1.00
CMS80F731x Reference Manual
21.2 I2C Port Configuration
If you use the I2C function, you should first configure the corresponding port as an SCL, SDA channel. For example,
configure P00, P01 port as I2C function:
PS_SCL = 0x00; Select the P00 port as the SCL pin
PS_SDA = 0x01; /Select the P01 port as the SDA pin
P00CFG = 0x02; P00 multiplexes the SCL function
P01CFG = 0x02; P01 multiplexed SDA function
After configuring the I2Cchannel, this group of ports defaults to the open-drain state, that is, the open-drain output when
outputting data 1. PxUP can be configured to enable SCL, the internal pull-up resistor of the SDA port, or to add a pull-up resistor
outside the chip.
21.3 I2C Master Mode
There are six registers for connecting to the master: control, status, slave address, transmit data, receive data, and timer
cycle registers.
register
address
write
Read
Slave address register I2CMSA
Slave address register I2CMSA
0xF4
Master mode control register I2CMCR
Master mode status register I2CMSR
0xF5
The master transmits the data register
I2CMBUF
The master receives data register I2CMBUF
0xF6
Timing cycle register I2CMTP
Timing cycle register I2CMTP
0xF7
The master mode control register I2CMCR shares a register address with the master mode status register I2CMSR, but is
physically two different registers.
The master transmit data register shares a register address with the master receive data register, and the write operation
accesses the transmit register I2CMBUF and the read operation accesses the receiving register I2CMBUF.
Write operations are written as control registers, and read operations are read as status registers.
21.3.1
I2C Master Mode Timing Cycle Register
To generate a wide range of SCL frequencies, the module has a built-in 8-bit timer. For standard and fast transfers.
TIMER_PRD ≠ 0, the clock period of the SCL: 2* (1+TIMER_PRD)*10* Tsys
TIMER_PRD = 0, the clock period of the SCL: 3* 10* Tsys
0xF7
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
I2CMTP
--
MTP6
MTP5
MTP4
MTP3
MTP2
MTP1
MTP0
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset value
0
0
0
0
0
0
0
1
Bit7
--
Reserved, must be 0.
Bit6~Bit0
MTP<6:0>:
Period timing registers in standard and fast modes, bits 6-0: TIMER_PRD [6:0].