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 mode_eeprom



使用官網上的SLAA208c程序,運行時,總是卡在void EEPROM_ByteWrite()中的UCB0CTL1 |= UCTXSTP;

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
}