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.

I2C MULTIPLE REGISTERS WITH ISR

Other Parts Discussed in Thread: MSP430G2553

hi every one,

my code is to write three registers in the slave device using MSP430g2553 using interrupts,without interrupts it is working but when i use interrupt only one register is perfectly writing

below is the code 

#include <msp430G2553.h>
unsigned int *PTxData; // Pointer to TX data
unsigned int TXByteCtr;

void init_I2C(void);
void Init_Clocks ();


const unsigned int TxData1[] = // Table of data to transmit register address,data
{

0X03,
0X40

};

const unsigned int TxData2[] = // Table of data to transmit
{

0X01,
0X81

};
const unsigned int TxData3[] = // Table of data to transmit
{

0X00,
0XFF

};
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1SEL |= BIT6 + BIT7; // Assign I2C pins to USCI_B0
P1SEL2|= BIT6 + BIT7;

Init_Clocks();
init_I2C();

while(1)
{
PTxData = (unsigned int *)TxData1;
TXByteCtr = sizeof TxData1;
while (UCB0CTL1 & UCTXSTP); 
UCB0CTL1 |= UCTR + UCTXSTT;
__bis_SR_register(CPUOFF + GIE);


PTxData = (unsigned int *)TxData2;
TXByteCtr = sizeof TxData2;
while (UCB0CTL1 & UCTXSTP);
UCB0CTL1 |= UCTR + UCTXSTT;
__bis_SR_register(CPUOFF + GIE);

PTxData = (unsigned int *)TxData3;
TXByteCtr = sizeof TxData3;
while (UCB0CTL1 & UCTXSTP);
UCB0CTL1 |= UCTR + UCTXSTT;
__bis_SR_register(CPUOFF + GIE);
UCB0CTL1 |= UCTXSTP;

}
}
void Init_Clocks (void)
{
BCSCTL1 = CALBC1_16MHZ; // Set DCO ~ 16 Mhz
DCOCTL = CALDCO_16MHZ;
BCSCTL1 |= DIVA_1; // ACLK/(0:1,1:2,2:4,3:8)
BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO
}
void init_I2C(void)
{
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_2 + UCSWRST+UCTR; // Use SMCLK, keep SW reset
UCB0BR0 = 200; // fSCL = SMCLK/12
UCB0BR1 = 0;
UCB0I2CSA = 0x52; // Slave Address i
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
IE2 |= UCB0TXIE; //Enable RX and TX interrupt
}
#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_ISR(void)
{
if (TXByteCtr) // Check TX byte counter
{
UCB0TXBUF = *PTxData++; // Load TX buffer
TXByteCtr--; // Decrement TX byte counter

}
else
{


__bic_SR_register_on_exit(GIE); // Exit LPM0
}

}

analysing the scope data i can find out only 0X52(slave address),0X03(register address),0X040(register data),0X01(2nd register address )only these are being sent after that it is getting stopped 

y its getting stopped abruptly is there any fault in the code 

Thank you 

**Attention** This is a public forum