title: TIva C Series problems with I2C Interface
body: <p>I'm currently trying to interface my Tiva C Series with a Sparkfun Breakout Board, IMU Digital Combo Board - 6 Degrees of Freedom ITG3200/ADXL345 and I'm having trouble with the I2C interface. </p>
  
  <p>currently this is my code:</p>
  
  <pre><code>#include &lt;stdint.h&gt;
  #include &lt;stdbool.h&gt;
  #include "inc/hw_memmap.h"
  #include "inc/hw_types.h"
  #include "driverlib/sysctl.h"
  #include "driverlib/gpio.h"
  #include "driverlib/i2c.h"
  
  uint8_t SLAVE_ADDRESS = 0x68;
  
  uint32_t first_byte, second_byte, temperature, result;
  
  void i2c_setup(void) {
  
  
  //Enable the I2C Module
  SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C2);
  
  SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
  
  //Wait at least 5 clock cycles
  SysCtlDelay(2);
  
  //Configure SDA and SCL
  GPIOPinConfigure(GPIO_PE4_I2C2SCL);
  
  GPIOPinConfigure(GPIO_PE5_I2C2SDA);
  
  //Wait at least 5 clock cycles
  SysCtlDelay(2);
  
  //Set PE4 as SCL
  GPIOPinTypeI2CSCL(GPIO_PORTE_BASE, GPIO_PIN_4);
  
  //Set PE5 as SDA
  GPIOPinTypeI2C(GPIO_PORTE_BASE, GPIO_PIN_5);
  
  //Configure Master,
  I2CMasterInitExpClk(I2C2_BASE, SysCtlClockGet(), false);
  
  }
  
  uint32_t i2c_read() {
  
  I2CMasterSlaveAddrSet(I2C2_BASE, SLAVE_ADDRESS, false);
  
  I2CMasterDataPut(I2C2_BASE, 0x1A);
  
  I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_SINGLE_SEND);
  
  while(I2CMasterBusBusy(I2C2_BASE)); //Loop until the bus is no longer busy
  
  I2CMasterSlaveAddrSet(I2C2_BASE, SLAVE_ADDRESS, true );
  
  I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
  
  while(I2CMasterBusBusy(I2C2_BASE)); //Loop until the bus is no longer busy
  
  first_byte = I2CMasterDataGet(I2C2_BASE);
  
  return first_byte;
  
  }
  
  void setup()
  {
  Serial.begin(9600);
  i2c_setup();
  }
  
  void loop()
  {
  
  int test = i2c_read();
  Serial.println(test);
  delay(1000);
  }
  </code></pre>
  
  <p>I'm using Energia to test my program, and when I try to read from the specified register, I get the same result, no matter which register I choose, the result is always decimal 229 (this is the Accelerometer's Device Address).</p>
  
  <p>Can somebody point me in the right direction, I've been looking at my code for quite some time and still don't know whats wrong...</p>
  
  <p>Thanks! </p>