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.
Hello MSP430 Team,
I have a question regarding the function USCI_B_I2C_masterSendMultiByteStart in the example code for MSP430F5529.
void USCI_B_I2C_masterSendMultiByteStart (uint16_t baseAddress,
uint8_t txData
)
{
//Store current transmit interrupt enable
uint8_t txieStatus = HWREG8(baseAddress + OFS_UCBxIE) & UCTXIE;
//Disable transmit interrupt enable
HWREG8(baseAddress + OFS_UCBxIE) &= ~(UCTXIE);
//Send start condition.
HWREG8(baseAddress + OFS_UCBxCTL1) |= UCTR + UCTXSTT;
// //Poll for transmit interrupt flag.
// while (!(HWREG8(baseAddress + OFS_UCBxIFG) & UCTXIFG)) ;
//Send single byte data.
HWREG8(baseAddress + OFS_UCBxTXBUF) = txData;
//Reinstate transmit interrupt enable
HWREG8(baseAddress + OFS_UCBxIE) |= txieStatus;
}
It seems after we send the first start condition, why do we need to poll for the transmit interrupt flag before putting something else in the UCBxTXBUF register?
What does this actually do?
Because if you put the byte in too early it will get lost. [Ref User Guide (SLAU208Q) Fig 38-12, top left]. The Start happens pretty fast, but not instantaneously.
> // while (!(HWREG8(baseAddress + OFS_UCBxIFG) & UCTXIFG)) ;
If you felt a need to remove this line, that may mean (a) your bus is hung (infinite clock-stretching by someone) or (b) one of the pullups got disconnected.
**Attention** This is a public forum