Example Summary
Sample application that reads the temperature from a TMP sensor.
Peripherals & Pin Assignments
When this project is built, the SysConfig tool will generate the TI-Driver configurations into the ti_drivers_config.c and ti_drivers_config.h files. Information on pins and resources used is present in both generated files. Additionally, the System Configuration file (*.syscfg) present in the project may be opened with SysConfig’s graphical user interface to determine pins and resources used.
CONFIG_GPIO_LED_0- Indicator LED.CONFIG_I2C_TMP- I2C bus used to communicate with the TMP sensor.CONFIG_GPIO_TMP_EN- Optional TMP power pin.
BoosterPacks, Board Resources & Jumper Settings
This example requires a BP-BASSENSORSMKII BoosterPack.
For board specific jumper settings, resources and BoosterPack modifications, refer to the Board.html file.
If you’re using an IDE such as Code Composer Studio (CCS) or IAR, please refer to Board.html in your project directory for resources used and board-specific jumper settings.
The Board.html can also be found in your SDK installation:
<SDK_INSTALL_DIR>/source/ti/boards/<BOARD>
Example Usage
Example output is generated through use of Display driver APIs. Refer to the Display driver documentation.
- Open a serial session (e.g.
PuTTY, etc.) to the appropriate COM port.- The COM port can be determined via Device Manager in Windows or via
ls /dev/tty*in Linux.
- The COM port can be determined via Device Manager in Windows or via
The connection will have the following settings:
Baud-rate: 115200
Data bits: 8
Stop bits: 1
Parity: None
Flow Control: None
Run the example.
CONFIG_GPIO_LED_0turns ON to indicate the I2C driver initialization is complete.I2C Initialized!If required, the TMP sensor is enabled using a GPIO output.
The I2C bus is queried for all supported TMP sensors. The output varies depending on which TMP sensor(s) is found.
I2C target address 0x49 not acknowledged! Detected TMP116 sensor with target address 0x48The last known TMP sensor will be used to read temperature samples. Samples are converted to celsius and displayed via UART.
Sample 0: 24 C Sample 1: 24 C . . . Sample 18: 24 C Sample 19: 24 CAfter a number of samples, the I2C driver instance is closed.
I2C closed!
If the I2C communication fails, an error message describing the failure is displayed.
I2C target address 0x49 not acknowledged!
Application Design Details
This application uses one task:
'mainThread' - performs the following actions:
Opens and initializes an I2C driver object.
Determines which TMP sensor is available. Sensors are described in the
sensorsdata structure at the top of the source.Uses the I2C driver in blocking mode to get data from the TMP sensor.
Extracts the temperature (in Celsius) and prints the value via the UART.
The task sleeps for 1 second.
FreeRTOS:
- Please view the
FreeRTOSConfig.hheader file for example configuration information.