Im post my code , while setting UCTR for transmitter mode, and setting UCTXSTT to generate a START condition. , in the I2C comm using 10Kohm pull resistor, i cant able figure out the problem , can any one help me , i hope i get quick solution from TI .
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT i have using setting default clock
PMAPPWD = 0x02D52; // Get write-access to port mapping regs
P1MAP3 = PM_UCB0SDA; // Map UCB0SDA output to P1.3
P1MAP2 = PM_UCB0SCL; // Map UCB0SCL output to P1.2
PMAPPWD = 0; // Lock port mapping registers
P1SEL |= BIT2 + BIT3; // Select P1.2 & P1.3 to I2C function
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset
UCB0BR0 = 12; // fSCL = SMCLK/12 = ~100kHz
UCB0BR1 = 0;
// UCB0I2COA = 0x48;
UCB0I2CSA = slave_address; // Slave Address is 048h
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
UCB0IE |= UCRXIE + UCSTPIE + UCSTTIE; // Enable RX interrupt
//UCB0IE |= UCRXIE;
//isr=1;
while (1)
{
__delay_cycles(50); // Delay required between transaction
PTxData = (unsigned char *)TxData; // TX array start address
// Place breakpoint here to see each
// transmit operation.
TXByteCtr = sizeof TxData; // Load TX byte counter
UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
//UCB0I2CSA = 000;
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, enable interrupts
__no_operation(); // Remain in LPM0 until all data
// is TX'd
while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
UCB0CTL1 &= ~ UCTR // I2C RX,
UCB0CTL1 |= ~UCTXSTT; //I2C Start
do
{
UCB0CTL1 |= UCTXSTT; // RE-START
while (UCB0CTL1&UCTXSTT); //wait for STT clear again
} while (UCB0STAT & UCNACKIFG);
PRxData = (unsigned char *)RxBuffer; // Start of RX buffer
RXByteCtr = 5; // Load RX byte counter
while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
UCB0CTL1 |= UCTXSTT; // I2C start condition
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, enable interrupts
// Remain in LPM0 until all data
// is RX'd
__no_operation(); // Set breakpoint >>here<< and
}
}
#pragma vector = USCI_B0_VECTOR
__interrupt void USCI_B0_ISR(void)
{
switch(__even_in_range(UCB0IV,12))
{
case 0: break; // Vector 0: No interrupts
case 2: break; // Vector 2: ALIFG
case 4: break; // Vector 4: NACKIFG
case 6: break; // Vector 6: STTIFG
case 8: break; // Vector 8: STPIFG
case 10: // Vector 10: RXIFG
RXByteCtr--; // Decrement RX byte counter
if (RXByteCtr)
{
*PRxData++ = UCB0RXBUF; // Move RX data to address PRxData
if (RXByteCtr == 1) // Only one byte left?
UCB0CTL1 |= UCTXSTP; // Generate I2C stop condition
}
else
{
*PRxData = UCB0RXBUF; // Move final RX data to PRxData
__bic_SR_register_on_exit(LPM0_bits); // Exit active CPU
}
break;
case 12: // Vector 12: TXIFG
if (TXByteCtr) // Check TX byte counter
{
UCB0TXBUF = *PTxData++; // Load TX buffer
TXByteCtr--; // Decrement TX byte counter
}
else
{
UCB0CTL1 |= UCTXSTP; // I2C stop condition
UCB0IFG &= ~UCTXIFG; // Clear USCI_B0 TX int flag
__bic_SR_register_on_exit(LPM0_bits); // Exit LPM0
}break;
default: break;
}
}
after sending command , the UCTXIFG does not set ,
Thank you.