• Not Answered

Writing problem in TMP006EVM from MSP430g2553

I want to read the data from TMP006EVM into msp430g2553 using USCI I2C. So i connected SCL of MSP430g2553 to SCL of TMP006 and similarly for SDA and Vcc and Gnd .

I have also connected P1.1 of msp430g2553 to DRDY pin of TMP006. I used the following program .While USing it runs well till " UCB0CTL1 |= UCTR + UCTXSTT;"

after this line, the "IFG2&UCB0TXIFG" flag is set which means that the slave address is successfully transmitted and the "UCB0STAT&UCNACKIFG" flag is not raised which means the slave has acknowledged the address. After this in order to configure the registers of TMP006 I had to write data from MSP .so i used "UCB0TXBUF = 0x02;"

The data here is not getting transferred to the TMP006 register, and I have come to know this because if the data is transferred  UCB0TXBUF   becomes empty and  "UCB0STAT&UCNACKIFG" is raised .But for me , the "UCB0STAT&UCNACKIFG" becomes zero instead and I have tried this with and without using "IFG2 &= ~UCB0TXIFG;"

and the result is the same and my program gets stuck in this loop "while (!(IFG2&UCB0TXIFG));"  I have pasted my code at the bottom and help me resolve this problem and also correct me if I am wrong . Pls it is urgent that I want this done and also thanks in advance.

* main.c
#define D1 BIT1
#define LED1 BIT0
void main(void) {
P1DIR |= LED1;
P1OUT &= ~LED1;
P1SEL |= BIT6+BIT7; // Assign I2C pins to USCI_B0
P1REN |= BIT1;
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset
UCB0BR0 = 12; // fSCL = SMCLK/12
UCB0BR1 = 0;
UCB0I2CSA = 0x40; // Slave Address is 048h
int i;
for ( i=0;i<100;i++)

while( UCB0STAT & UCBBUSY );


UCB0TXBUF = 0x02;
while( UCB0STAT & UCBBUSY );
while (!(IFG2&UCB0TXIFG)) ////This is the part where my program hangs .


UCB0TXBUF = 0x75;
while (!(IFG2&UCB0TXIFG))

UCB0TXBUF = 0x00;
while (!(IFG2&UCB0TXIFG))

while ((UCB0CTL1&UCTXSTP))

while((P1IN & D1) == 0)

for ( i=0;i<30;i++)

P1OUT |= LED1;


3 Replies

  • ARUN kumar95269
    after this line, the "IFG2&UCB0TXIFG" flag is set which means that the slave address is successfully transmitted

    No. TXIFG is set as soon as you set UCTXSTT and are itransmit mode (UCTR set). It doe sNOT mean that anything has been sent yet, i t only means that TXBUF is ready to receive the first byte.
    Teh address has been sent if UCTXSTT clears. Then you'll have to check for UCNACKIFG. If it is clear, and you wrote to UCTXBUF before, then the content of TXBUF is already sending, without delay. If UCNACKIFG is set, the content of TXBUF is discarded and TXIFG is cleared (if it wasn't already clear because of a write to TXBUF).

  • Hi! In a similar way to the project you were describing, I am also trying to read the output of the TMP006EVM, yet using an Arduino Mega board. I have connected the 4 pins: SCL, SDA, +3.3V, and GND. I am not sure how you discovered the slave address 0x40 (I am a bit confused because in the comments you specify 0x48). I read all the documentation I could find and have not managed to map that address to anything. I am a computer science person, so it is the first time I am dealing with the I2C protocol, therefore any help with be highly appreciated! More precisely I have the following questions:

    1. how to get the slave address for the TMP006EVM

    2. what registers am I supposed to read and how, if I want to ultimately obtain the temperature of an object 

    #include <Wire.h>

    void setup()
    Wire.begin(); // join i2c bus (address optional for master)
    Serial.begin(115200); // start serial for output

    void loop()
    Wire.requestFrom(0x40, 32); // request 32 bytes from slave device #0x40

    while(Wire.available()) // slave may send less than requested
    double c = Wire.read(); // receive a byte as character
    Serial.print(c); // print the character

    The output of this piece of code is.00255.
    Many thanks!
  • In reply to Carmen Banea:

    Carmen Banea
    I am not sure how you discovered the slave address 0x40

    In USCI module, the slave address ot be used is the upper 7 bits of the 'usual' slave address ohnly, omitting th eLSB, which actually isn't part of the address, but rather the direction bit and included into the address in most I2C slave manuals. The USCI will automatically add this bit based on the UCTR bit when addressing the slave, but the slave address register only gets the upper 7 bits, right-justified.