I'm trying to interface BMP180 with TM4C1294 ncpdt via i2c protocol. But not able to read the temperature values.
Device Address - 0xEF (read) and 0xEE (write).
Link for BMP180 Datasheet - cdn-shop.adafruit.com/.../BST-BMP180-DS000-09.pdf
Below is the code what i have tried to implement, please any suggestions on the issue. Thanks in advance.
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_i2c.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "driverlib/i2c.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#define DEVICE_ADDRESS 0xEF
#define W_DEVICE_ADDRESS 0xEE
#define regADD 0x2E
//#define regADD 0xF//0xF6
void InitI2C0()
{
//enable I2C module 0
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
//reset module
SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0);
//enable GPIO peripheral that contains I2C 0
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
// Configure the pin muxing for I2C0 functions on port B2 and B3.
GPIOPinConfigure(GPIO_PB2_I2C0SCL);
GPIOPinConfigure(GPIO_PB3_I2C0SDA);
// Select the I2C function for these pins.
GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
// Enable and initialize the I2C0 master module. Use the system clock for
// the I2C0 module. The last parameter sets the I2C data transfer rate.
// If false the data rate is set to 100kbps and if true the data rate will
// be set to 400kbps.
I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), false);
//clear I2C FIFOs
HWREG(I2C0_BASE + I2C_O_FIFOCTL) = 80008000;
//HWREG(I2C0_BASE + I2C_O_MCR) |= 0x01;
}
uint32_t ReadTemp(uint32_t W_slave_address, uint32_t R_slave_address, uint8_t regadd)
{
//specify that we are writing (a register address) to the
//slave device
I2CMasterSlaveAddrSet(I2C0_BASE, R_slave_address, false);
//specify register to be read
I2CMasterDataPut(I2C0_BASE, regadd);
//send control byte and register address byte to slave device
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);
//wait for MCU to finish transaction
while(I2CMasterBusy(I2C0_BASE));
//specify that we are going to read from slave device
I2CMasterSlaveAddrSet(I2C0_BASE, R_slave_address, true);
//send control byte and read from the register we
//specified
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
//wait for MCU to finish transaction
while(I2CMasterBusy(I2C0_BASE));
//return data pulled from the specified register
return I2CMasterDataGet(I2C0_BASE);
}
void main(void)
{
// Set the clocking to run directly from the external crystal/oscillator.
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_INT | SYSCTL_XTAL_16MHZ);
//initialize I2C module 0
InitI2C0();
uint32_t Data;
Data = ReadTemp(W_DEVICE_ADDRESS, DEVICE_ADDRESS, regADD);
SysCtlDelay(5000);
Data = ReadTemp(W_DEVICE_ADDRESS, DEVICE_ADDRESS, regADD);
while(1)
{
}
}