This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP430F249: Read multiple bytes In I2C Communication

Part Number: MSP430F249

Tool/software: Code Composer Studio

Hello

I'm trying to use a temperature sensor(PCT2075) by MSP430

To get a temperature, I get a 2bytes from this sensor. 

Howerver, I got just two same value. I think that it is MSByte.

I wrote a code from this link.

https://e2e.ti.com/support/microcontrollers/msp430/f/166/t/589712?MSP430FR5969-Read-multiple-bytes-of-data-i2c-with-repeated-start-and-without-interrupts

I'm using MSP430F249. so I modified  a code from this link.

void i2c_read_multi(uint8_t slv_addr, uint8_t reg_addr, uint8_t l, uint8_t *arr)
{
   uint8_t i;

   while(UCB0STAT & UCBBUSY);

   UCB0I2CSA = slv_addr;                   // set slave address

   UCB0CTL1 |= UCTR | UCTXSTT;            // transmitter mode and START condition.

   while(UCB0CTL1 & UCTXSTT);

   UCB0TXBUF = reg_addr;

   while(!(UCB0CTL1 & UCTXSTT));

   UCB0CTL1 &= ~UCTR;                     // receiver mode

   UCB0CTL1 |= UCTXSTT;                   // START condition

   while(UCB0CTL1 & UCTXSTT);             // make sure start has been cleared

   for (i = 0; i < l; i++) {

       while(!(IFG2 & UCB0RXIFG));

       if(i == l - 1){

           UCB0CTL1 |= UCTXSTP;           // STOP condition

       }

       arr[i] = UCB0RXBUF;

   }

   while(UCB0CTL1 & UCTXSTP);

}