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/MSP430F2274: i2c master receiver program does not receive the rx buffer data from master program code

Part Number: MSP430F2274
Other Parts Discussed in Thread: MSP430WARE

Tool/software: Code Composer Studio

hi friends,

i am  connected light sensor and msp430f2274  with i2c interface.

i write program code for I2C master receiver program in CCSV5.1

But the transmiter the data and store in data in TXbuffer but it doesnot send at  rxBUFFER.

What is the problem?

BCSCTL1 = CALBC1_16MHZ;                             // Set DCO to calibrated 16MHz
    DCOCTL = CALDCO_16MHZ;
    BCSCTL2 |= DIVS_3;                                  // SMCLK to 2 MHz

PORT_I2C_SEL |= BIT2 | BIT1;                        // Set I/O pins 1 and 2 for port 3 to be for the  //   I2C peripheral
    //PORT_I2C_DIR |= BIT0;                               // Set port 3 pin 0 as output and set high.   PORT_I2C_OUT |= BIT0;
    UCB0CTL1 |= UCSWRST;                                // Put state machine in reset
    UCB0CTL0 |= UCMST + UCSYNC + UCMODE_3;              // I2C mode, master, synchronous
    UCB0CTL1 = UCSSEL_2 + UCSWRST;                               // SMCLK as clock source
    UCB0BR0 = 3;                                        // 2MHz/5 = 400kHz
    UCB0BR1 = 0;
    UCB0I2CSA = 0x39;                                   // Slave Address is 1Eh
    UCB0CTL1 &= ~UCSWRST;                               // Start I2C state machine
    IE2|=UCB0RXIE;                                         //ENABLE Rx interrupt

unsigned char i2c_read(unsigned char regAddress)
{
unsigned char Result;
UCB0CTL1 |= UCTR + UCTXSTT;                         // I2C TX, start condition
//while (!(IRQ_REG & TX_IFG));                        // Wait for slave address transmit to complete
TX_BUFFER = regAddress;                                // Load TX buffer with register address
//while (!(IRQ_REG & TX_IFG));                        // Wait for transmit to complete
IRQ_REG &= ~TX_IFG;                                 // Clear USCI_B0 TX int flag
// Send restart with transmit/receive bit NOT set
UCB0CTL1 &= ~UCTR;                                  // Toggle transmitter bit
UCB0CTL1 |= UCTXSTT;                                // I2C start condition
//while(UCB0CTL1 & UCTXSTT);                          // Wait for start to complete
UCB0CTL1 |= UCTXSTP;                                // I2C stop condition
//while (!(IRQ_REG & RX_IFG));                        // Wait for receive buffer to fill
Result = RX_BUFFER;                                 // Fill receive data buffer with received byte
//while (UCB0CTL1 & UCTXSTP);                         // Wait for stop condition to complete
IRQ_REG &= ~RX_IFG;                                 // Clear USCI_B0 RX int flag  return Result;
}

is it right code for read the data from receiver to send the transmitter then the store in rxbuffer.

can u any body send the program for received the data from slave device 

i2c adress= 0x39;

only two bytes receiver from slave device.

so please me as possible soon..

**Attention** This is a public forum