|
使用GPIO读写eeprom没问题后
想学习I2C mode
下了TI的SLAA208c范例來调适
其中
void EEPROM_ByteWrite(unsigned int Address, unsigned char Data)
{
unsigned char adr_hi;
unsigned char adr_lo;
while (UCB0STAT & UCBUSY); // wait until I2C module has
// finished all operations.
adr_hi = Address >> 8; // calculate high byte
adr_lo = Address & 0xFF; // and low byte of address
I2CBufferArray[2] = adr_hi; // Low byte address.
I2CBufferArray[1] = adr_lo; // High byte address.
I2CBufferArray[0] = Data;
PtrTransmit = 2; // set I2CBufferArray Pointer
I2CWriteInit();
UCB0CTL1 |= UCTXSTT; // start condition generation
// => I2C communication is started
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts
UCB0CTL1 |= UCTXSTP; // I2C stop condition
while(UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
}
运行时会卡在这↘
UCB0CTL1 |= UCTXSTP;
如遮蔽再运行↘
__bis_SR_register(LPM0_bits + GIE);
则会卡在这↘
while(UCB0CTL1 & UCTXSTP);
不了解为何会卡住
|
|