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!