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.

I2C bsp code is not works and scl line is low even slave having pullup resistor

Other Parts Discussed in Thread: MSP430F6438

Hi

I am trying to implement i2c data transmission in interrupt mode for msp430f6438 data is transmission is happen but when i want to see data in logic analyzer its not showing and always i2c scl pin is low even slave device having pull up 2k  and code shown below and my slave device is operating with 100khz.please help me

 

void I2CMaster_Init();

unsigned char *PTxData;                     // Pointer to TX data

unsigned char TXByteCtr;

unsigned char RXData;

unsigned char RXCompare;

unsigned char TxData[] = // Table of data to transmit

{

  0x00

};

int main(void)

{

 

  uint32_t initstatus = I2C_Success;

  unsigned int i,j;

  WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog

  I2CMaster_Init();

  PTxData = 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

  while (1)

  {

    PTxData = TxData;      // TX array start address

                                            // Place breakpoint here to see each

                                            // transmit operation.

    TXByteCtr = sizeof(TxData);              // Load TX byte counter

    __bis_SR_register(GIE);     // Enter LPM0, enable interrupts

  }

  return 0;

}

 

void I2CMaster_Init()

{

  unsigned int i;

  P2SEL |= 0x06;                            // Assign I2C pins to USCI_B0

  //P2DIR &= ~0x06;

  P2REN |= 0x04;

  P2OUT |= 0x04;

  UCB0CTL1 |= UCSWRST;                      // Enable SW reset

  UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC;     // I2C Master, synchronous mode

  UCB0CTL1 |= UCSSEL_2;            // Use SMCLK, keep SW reset

  UCB0BR0 = 10;                             // fSCL = SMCLK/12 = ~100kHz

  UCB0BR1 = 0;

  UCB0I2CSA = 0x18;                         // Slave Address is 048h

  UCB0CTL1 &= ~UCSWRST;                     // Clear SW reset, resume operation

condition

  UCB0IE |= UCTXIE + UCRXIE;                         // Enable TX interrupt

  //for(i=0;i<50;i++);

 

}

// USCI_B0 Data ISR

#pragma vector = USCI_B0_VECTOR

__interrupt void USCI_B0_ISR(void)

{

  unsigned int j;

  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   

    RXData = UCB0RXBUF;                     // Get RX data

    printf("hai");

    UCB0CTL1 |= UCTXSTP;                    // I2C start condition

    break;

  case 12:                            // Vector 12: TXIFG 

    while(TXByteCtr)                      // Delay required between transaction

    {

   

      UCB0TXBUF = *PTxData++;               // Load TX buffer

      TXByteCtr--;     

    }

    UCB0IFG &= ~UCTXIFG;                  // Clear USCI_B0 TX int flag

   // UCB0CTL1 &= ~UCTR ;             // I2C recivecondition

  default: break;      

  }

}

Thanks in advance

**Attention** This is a public forum