The following described the necessary steps to configure the I2C module to transmit a single byte as a master, assuming that the system clock is 24 MHz.
TI recommends using the I2C driver in the SimpleLink™ CC13xx and CC26xx software development kit (SDK)
- Enable the serial power domain and enable the I2C module in PRCM by writing to PRCM:I2CCLKGR, PRCM:I2CCLKGS, and PRCM:I2CCLKGDS register, and load the setting to the clock controller by writing to the PRCM:CLKLOADCTL register
- Configure the IOC module to route the SDA and SCL signals from I/Os to the I2C module
- Initialize the I2C master by writing the I2C:MCR register with a value of 0x00000010
- Set the desired SCL clock speed of 100 kbps by writing the I2C:MTPR register with the correct value. The value written to the I2C:MTPR register represents the number of system clock periods in one SCL clock period. The TPR value is determined by Equation 11, Equation 12, and Equation 13.
Equation 11. TPR = [PERDMACLK / (2 × (SCL_LP + SCL_HP) × SCL_CLK)] – 1
Equation 12. TPR = [24 MHz / (2 × (6 + 4) × 100000)] – 1
Equation 13. TPR = 11
Write the I2C:MTPR register with the value of 0x0000000B
- Specify the slave address of the master and that the next operation is a transmit by writing the I2C:MSA register with a value of 0x00000076, which sets the slave address to 0x3B
- Place data (byte) to be transmitted in the data register by writing the I2C:MDR register with the desired data
- Initiate a single-byte transmit of the data from master to slave by writing the I2C:MCTRL register with a value of 0x00000007 (Stop, Start, Run)
- Wait until the transmission completes by polling the I2C:MSTAT BUSBSY register bit until it is cleared
- Check the I2C:MSTAT ERR register bit to confirm the transmit was acknowledged