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.

can't send STOP in I2C MSP430

Other Parts Discussed in Thread: MSP430G2112

Hi all !

I have a problem. I'm using MSP430G2112 interfaces RTC DS1307. Writing is OK, but when I read time from DS1307, I only receive the first character, then I can't send STOP signal, program is trap, so I can't receive other charater. This is my code.

void read_DS1307(char data_rec[], char len)
{
char i;
UCB0I2CSA = DS1307_addr;
bis(UCB0CTL1, UCTR); //cai dat mode transmitter
while ( (UCB0CTL1 & UCTXSTP ) );
bis(UCB0CTL1, UCTXSTT); //gui tin hieu START


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

bis(UCB0CTL1, UCTXSTP);
while( (UCB0CTL1 & UCTXSTP) );

//=======================================================================================

bic(UCB0CTL1, UCTR);
bis(UCB0CTL1, UCTXSTT);

while( (UCB0CTL1 & UCTXSTT));
while( (UCB0STAT & UCNACKIFG) );

for(i=0;i<len-1;i++)
{
while ( !(IFG2 & UCB0RXIFG));
data_rec[i] = UCB0RXBUF;
};

while ( !(IFG2 & UCB0RXIFG));
data_rec[len-1] = UCB0RXBUF;

bis(UCB0CTL1, UCTXSTP);
while(UCB0CTL1 & UCTXSTP);

}

sorry for my EngLish. Thanhks a lot!

**Attention** This is a public forum