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.
unsigned char EEprom_readbyte(unsigned char addr,unsigned char* data)
{
UCB0CTL1 |= UCTR;
UCB0CTL1 |= UCTXSTT;
UCB0TXBUF = addr;
while(!(IFG2 & UCB0TXIFG))
{
if(UCB0STAT & UCNACKIFG)
{
return 1;
}
}
UCB0CTL1 &= ~UCTR;
UCB0CTL1 |= UCTXSTT;
while(UCB0CTL1 & UCTXSTT);
UCB0CTL1 |= UCTXSTP;
while((IFG2 & UCB0RXIFG) == 0);
*data = UCB0RXBUF;
while(UCB0CTL1 & UCTXSTP);
return 0;
}
我的代码,在读EEprom时,接收的数据有的时候是上一次的数据的,当前的数据 ,要到下次读的时候才能读到,感觉UCB0RXIFG 标志位没有清除 ?