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.

MSP430硬件I2C总是读出0xFF,但是在线观察是正确的



其中

unsigned char i2c_rx()

{

  unsigned char rx_dat;

  while (UCB0CTL1 & UCTXSTT);

  while ( (UCB0IFG & UCRXIFG)==0 );

  rx_dat = UCB0RXBUF;

  return rx_dat;

}

接收一个字节是这样的程序.

 

这个i2c库是我自己写的,发送部分一点问题都没有.就是接收,rx_data = i2c_rx(); 总是不对 ,好是郁闷

我真的很奇怪,明明RXBUF中是0xee,为什么赋值一下就不对了呢.