English
Language : 

LM3S1N16 Datasheet, PDF (691/794 Pages) Texas Instruments – Stellaris® LM3S1N16 Microcontroller
Stellaris® LM3S1N16 Microcontroller
7. Set the desired SCL clock speed of 100 Kbps by writing the I2CMTPR register with the correct
value. The value written to the I2CMTPR register represents the number of system clock periods
in one SCL clock period. The TPR value is determined by the following equation:
TPR = (System Clock/(2*(SCL_LP + SCL_HP)*SCL_CLK))-1;
TPR = (20MHz/(2*(6+4)*100000))-1;
TPR = 9
Write the I2CMTPR register with the value of 0x0000.0009.
8. Specify the slave address of the master and that the next operation is a Transmit by writing the
I2CMSA register with a value of 0x0000.0076. This sets the slave address to 0x3B.
9. Place data (byte) to be transmitted in the data register by writing the I2CMDR register with the
desired data.
10. Initiate a single byte transmit of the data from Master to Slave by writing the I2CMCS register
with a value of 0x0000.0007 (STOP, START, RUN).
11. Wait until the transmission completes by polling the I2CMCS register’s BUSBSY bit until it has
been cleared.
12. Check the ERROR bit in the I2CMCS register to confirm the transmit was acknowledged.
15.5
Register Map
Table 15-3 on page 691 lists the I2C registers. All addresses given are relative to the I2C base address:
■ I2C 0: 0x4002.0000
■ I2C 1: 0x4002.1000
Note that the I2C module clock must be enabled before the registers can be programmed (see
page 244). There must be a delay of 3 system clocks after the I2C module clock is enabled before
any I2C module registers are accessed.
The hw_i2c.h file in the StellarisWare® Driver Library uses a base address of 0x800 for the I2C slave
registers. Be aware when using registers with offsets between 0x800 and 0x818 that StellarisWare
uses an offset between 0x000 and 0x018 with the slave base address.
Table 15-3. Inter-Integrated Circuit (I2C) Interface Register Map
Offset Name
I2C Master
0x000 I2CMSA
0x004 I2CMCS
0x008 I2CMDR
0x00C I2CMTPR
0x010 I2CMIMR
0x014 I2CMRIS
Type
Reset
Description
R/W
0x0000.0000 I2C Master Slave Address
R/W
0x0000.0020 I2C Master Control/Status
R/W
0x0000.0000 I2C Master Data
R/W
0x0000.0001 I2C Master Timer Period
R/W
0x0000.0000 I2C Master Interrupt Mask
RO
0x0000.0000 I2C Master Raw Interrupt Status
See
page
693
694
699
700
701
702
January 21, 2012
691
Texas Instruments-Production Data