NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
CC3200 I2C Application
Contents
Overview[edit]
The Inter-Integrated Circuit (I2C) bus provides bi-directional data transfer through a two-wire design (a serial data line SDA and a serial clock line SCL),and interfaces to external I2C devices.On the LaunchPad there are two sensors connected over the I2C namely Accelerometer and Temperature sensor. The I2C lines are also brought out on the header for further expansion (to connect to sensors on booster packs).
Application details[edit]
The objective of this application is act as an I2C diagnostic tool. The demo application is a generic implementation that allows the user to communicate with any I2C device over the lines.
The features supported by the application are:
- I2C write: Performs write operation to the specifed I2C device address. User also needs to specify if the stop bit needs to be set or not (To support specifying and reading from a particular register).
- I2C Read: Performs I2C read from the specified I2C device address.
- I2C Readreg: Is a combination of I2C write (without stop bit) + I2C read. This is useful to get register values from the specified register offset from a I2C device.
This command assumes the register offset to be 1 byte.
- I2C Writereg: Performs an I2C writes from the specified offset register. This command assumes the register offset to be 1 byte.
Note: The write and read are core APIs that follow the I2C specification for its operation. They are generic and can be used to communicate with any I2C device.
Note: The readreg and writereg are ready to use APIsthat internally invoke the read and write functionality. These have been provided for ease of use and is not guaranteed to work for all I2C devices due to some assumptions made.
Source Files briefly explained[edit]
- main: - Prompts and services the user options by invoking the i2c_if APIs.
- i2c_if: - I2C access interface APIs. This works in a polled mode of operation.
- pinmux: - Pinmux configurations as required by the application.
- startup_*: - Tool specific vector table implementation.
- uart_if: - To display status information over the UART
Usage[edit]
Note: For this application to work, one needs to populate jumpers at j2 and j3 on LP 3.x
- Setup a serial communication application (HyperTerminal/TeraTerm). For detail info visit Terminal setup
On the host PC, open a hyperterminal, with the following settings- Port: 2nd enumerated COM port
- Baud rate: 115200
- Data: 8 bit
- Parity: None
- Stop: 1 bit
- Flow control: None
- Run the reference application (Flashing the bin/IAR/CCS).
- Open the Project as mentioned in the 'docs\CC3200-Getting Started Guide.pdf'
- Build and download the application to the board
- On the Hyperterminal, a prompt appears
- The I2C commands need to be issued and the results can be seen
CC3200 I2C Example Usage
Commands:
- write <dev_addr> <wrlen> <<byte0> [<byte1> ... ]> <stop>
- read <dev_addr> <rdlen>
- writereg <dev_addr> <reg_offset> <wrlen> <<byte0> [<byte1> ... ]>
readreg <dev_addr> <reg_offset> <rdlen>
Parameters:
dev_addr - slave address of the i2c device, a hex value preceeded by '0x'
reg_offset - register address in the i2c device, a hex value preceeded by '0x'
wrlen - number of bytes to be written, a decimal value
rdlen - number of bytes to be read, a decimal value
bytex - value of the data to be written, a hex value preceeded by '0x'
stop - number of stop bits, 0 or 1
Note: The user can determine the device address of a particular component by looking at its respective datasheet.
- The temperature sensor used is tmp006, and its device address (dev_addr) is 0x41
- The accelerometer sensor used is bma222, and its device address (dev_addr) is 0x18
For instance
- To read the manufacturer id register (0xFE) of the temperature sensor (0x41), the command will be
readreg 0x41 0xFE 2
- To read the "who am i" register (0x00) of the accelerometer sensor (0x18), the command will be
readreg 0x18 0x00 1
Snapshot of the Hyperterminal when the application starts.
Limitations/Known Issues[edit]
- This example exercise only standard speeds(100Kbps and 400Kbps) for I2C clock. High speed(1 Mbps and 3.3 Mbps) I2C clocks are supported in driverlib, but not exercised in this example.
- Populating the jumpers J2 and J3 will turn the LED D5 and D6 on and hence will not be available for use.
Links[edit]
{{#invoke: Navbox | navbox }} {{#invoke: Navbox | navbox }}