Hej,
i have a problem with the I2C communication between a MSP430f2132 and a Fuel Gauge from LT .
To start the communication like its dokumented you have to UCTR to 0 (yellow highlighted) and send the start condition. But if i do so i'm running in a trap (green Highlighted) normally this bit (UCTXSTT) is set back when the startcondition is sent but not in this case. Is there any workaround to fix this problem?
Thank you very much
franz
void i2c_start(){
UCB0CTL1 |= UCTXSTT; // I2C start condition
while (UCB0CTL1 & UCTXSTT); // Loop until I2C STT is sent
}
void i2c_stop(){
UCB0CTL1 |= UCTXSTP; // Stop
while (UCB0CTL1 & UCTXSTP);
}
void i2c_write(unsigned char cmd, unsigned char data){
UCB0CTL1 &= ~UCTR; // I2C TX
i2c_start();
UCB0TXBUF = cmd; // write register
while(IFG2 & UCB0TXIFG);
UCB0TXBUF = data; // write data
while(IFG2 & UCB0TXIFG);
i2c_stop();
}
