title: MSP430 I2C reading a SDP610 differential pressure sensor issue
body: <p>I am trying to read a SDP610 sensiron differential pressure sensor via a Texas Instruments msp430.
  I am having the issue of the sensor not acknowledging the command and thus, not communicating the pressure value itself. Note I have confirmed that the sensor works by hooking it up to an arduino via an opensource library and, I can see the data via this. Note my IDE is code composer. My chips is MSP430FR2311 (a launch pad breakout board).</p>
  
  <p>My hardware setup is 4 wires. Vcc(3.3V), Ground(0V), SDK and SCL. The SDK and SCL lines are pulled to VCC with a 4.7Kohm resistor as per specification.</p>
  
  <p>I have the following code for my MSP430 see below:</p>
  
  <p>However, I do not see the response of the sensor via a logic analyser. Here is my capture. You will have to click the link. Note the top line is clock and bottom is the data.
  <a href="https://i.stack.imgur.com/DKan4.png" rel="nofollow noreferrer">MSP430 output</a>.
  The logic flow for reading the sensor from the datasheet and from the arduino code is as follows:</p>
  
  <ul>
  <li>Write address of the device to the I2C line(8 bit h81)</li>
  <li>Wait for slave acknowledge</li>
  <li>Write command for reading (8 bit hF1)</li>
  <li>Wait for slave acknowledge</li>
  <li>Slave holds the master</li>
  <li>Slave outputs 3 bytes (2 data one msb and 1 lsb then a check sum)</li>
  <li>acknowledge</li>
  </ul>
  
  <p><a href="https://www.sensirion.com/fileadmin/user_upload/customers/sensirion/Dokumente/8_Differential_Pressure/Datasheets/Sensirion_Differential_Pressure_Sensors_SDP600Series_Datasheet.pdf" rel="nofollow noreferrer">This is the datasheet for the sensor</a></p>
  
  <p>Any tips to why the sensor is not responding.</p>
  
  <p><strong><em>CODE</em></strong></p>
  
  <pre><code>void Read_Diff_pressure(void)
  {
      int rx_byte;
      UCB0CTL1 |= UCTXSTT+ UCTR; // Generating START + I2C transmit (write)
      UCB0I2CSA = SDP610Address; // SDP610 7 bit address 0x40
      UCB0TXBUF = SDP610Read; // sending the read command 0x78
      while(!(UCB0IFG &amp; UCTXIFG)); //wait until reg address got sent
      while( UCB0CTL1 &amp; UCTXSTT); //wait till START condition is cleared
      UCB0CTL1 |= UCTXSTT; //generate RE-START
      UCB0I2CSA = SDP610Address; // SDP610 7 bit address 0x40
      UCB0CTL1 &amp;=~ UCTR; //receive mode
      while( UCB0CTL1 &amp; UCTXSTT); //wait till START condition is cleared
      rx_byte = UCB0RXBUF; //read byte
      //while(!(UCB0IFG &amp; UCRXIFG)); //wait while the Byte is being read
      UCB0CTL1 |= UCTXNACK; //generate a NACK
      UCB0CTL1 |= UCTXSTP; //generate stop condition
      while(UCB0CTL1 &amp; UCTXSTP); //wait till stop condition got sent```
  
      Pressure_result = rx_byte;
  }
  </code></pre>
  
  <pre><code>void InitI2C_diff(void)
  {
  
      PAOUT |= I2C_SCL_PIN|I2C_SDA_PIN;//P1.2(SDA) - P1.3(SCL) as per silk screen defined in a header
      PADIR |= I2C_SCL_PIN|I2C_SDA_PIN;
      PASEL0 |= (I2C_SCL_PIN|I2C_SDA_PIN);              // configure I2C pins (device specific)
      UCB0CTLW0 |= UCSWRST;                             // put eUSCI_B in reset state
      UCB0CTLW0 |= UCMODE_3 | UCSYNC | UCMST;           // I2C master mode, SMCL
      UCB0CTL1 = UCSSEL_2 + UCSWRST; //use SMCLK + still reset
      UCB0BR0 = 10; // default SMCLK 1M/10 = 100KHz
      UCB0BR1 = 0; //
      UCB0I2CSA =  SDP610Address;                       //The address of the device
      UCB0CTLW0 &amp;= ~UCSWRST;                            // eUSCI_B in operational state
  
      //UCB0BRW = 64;                                     // baudrate = SMCLK / 64
  }
  </code></pre>
  
  <pre><code>int main(void)
  {
      InitI2C_diff();//Init the i2c
  
  
      while (1) { // Mainloop
          Read_Diff_pressure();
          delay(1000);//1 Second delay before re looping
      }
  }
  </code></pre>