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.
This won't happen if no slave answers to the start.Scott Brenneman said:UCB0CTL1 |= UCTR + UCTXSTT; // I2C Transmit mode; send START
while (IFG2 & ~UCB0TXIFG); // Wait for readiness of transmit buffer
You should look for STT being cleared (then the address has been sent, whether a slave has responded or not). After this, either TX starts or a NACK is set.
I don't think this works. On USCI (other than the previous UART), the IFGs are state flags (level-set) and not change flags (edge-set). This means TXIFG remains set until you write something into TXBUF or disable the TX functionality. At least on the 5x USCIs it is this way. Anyway, it won't make a difference for the code.Scott Brenneman said:IFG2 &= ~UCB0TXIFG; // Clear USCI_B0 TX flag
No need to send a stop, you can just follow another start (this will nto free the bus, so no other master could interfere). Just send another start (repeated start condition - it's even faster since you spare the time for the stop)Scott Brenneman said:UCB0CTL1 |= UCTXSTP; // I2C STOP will be sent at end of byte
I don't see, however, something that would stall the code unde rnormal circumstances.
Unnormal cisrumstacnes owudl be that ne slave is answering (your code simply assumes that there is always a slave responding) and th emother of all I2C problems: a missing pullup on the clock/data lines that causes the clock line to stay low and stall the bus (clock-stretching: the slave keeps the clock low to signal the master that it needs more time. The master will wait until the slave releases the clock line. there is no timeout). The MSPs internal pullups are too weak to server for the I2C bus and on most MSPs they are disabled anyway if the port pin is set to output.
**Attention** This is a public forum