Other Parts Discussed in Thread: BOOSTXL-BATPAKMKII
Tool/software: Code Composer Studio
Hello TI team,
I'm using MSP430F5529LP to communicate with BOOSTXL‑BATPAKMKII via I2C.
This is a code source of a function USCI_B_I2C_masterSendSingleByteWithTimeout from usci_b_i2c.c (msp430 driverlib)
bool USCI_B_I2C_masterSendSingleByteWithTimeout(uint16_t baseAddress,
uint8_t txData,
uint32_t timeout)
{
// Creating variable for second timeout scenario
uint32_t timeout2 = timeout;
//Store current TXIE status
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)) && --timeout)
{
;
}
//Check if transfer timed out
if(timeout == 0)
{
return (STATUS_FAIL);
}
//Send single byte data.
HWREG8(baseAddress + OFS_UCBxTXBUF) = txData;
//Poll for transmit interrupt flag.
while((!(HWREG8(baseAddress + OFS_UCBxIFG) & UCTXIFG)) && --timeout2) // ======> code block here
{
;
}
//Check if transfer timed out
if(timeout2 == 0)
{
return (STATUS_FAIL);
}
//Send stop condition.
HWREG8(baseAddress + OFS_UCBxCTL1) |= UCTXSTP;
//Clear transmit interrupt flag before enabling interrupt again
HWREG8(baseAddress + OFS_UCBxIFG) &= ~(UCTXIFG);
//Reinstate transmit interrupt enable
HWREG8(baseAddress + OFS_UCBxIE) |= txieStatus;
return (STATUS_SUCCESS);
}
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;
}
After some research on E2E forum I understand that it might be the pull-up resistors on the SDA and SCL issues. Is this the right problem ??
if Yes, How can I set the the pullup resistors in the SDA and SCL pin enabled ??
By the way I put this line into my code but it didn't resolve my problem.
P4REN |= 0x06;
Thank you.