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 start condition not executing

Other Parts Discussed in Thread: MSP430FG4618

I am interfacing MSP430FG4618 with DS1307 using I2c protocol.  i am a newbeee in controller,

when i need to write to DS1307 i do the folowing procedure, but there is problem at bold line below, ( UCB0CTL1 |= UCTR+UCTXSTT;   ) when this instruction is executed, the UCTXSTT bit does not set, i.e. it remains zero.  i do not understand why this is,  is there any hardware problem? please help

 

UCB0CTL1 |= UCSWRST;                //force to have software reset
   
    P3SEL |= 0x06;
   UCB0CTL0 =UCMST + UCMODE_3 + UCSYNC;     // I2C Master, synchronous mode
  
   UCB0CTL1 = UCSSEL_1+ UCSWRST;   // Use ACLK, keep SW reset 
 
    UCB0BR0 = 1;                             // fSCL = ACLK/1 = 32.768kHz
    UCB0BR1 = 0;

 
    UCB0CTL1 &= ~UCSWRST;                     // Clear SW reset, resume operation
    IE2 |= UCB0RXIE;                        // Enable RX interrupt
      UCB0I2CSA = 0xD0;                         // Set slave address
      UCB0CTL1 |= UCTR+UCTXSTT;               // I2C TX, start condition
    

     UCB0TXBUF = 0x00;              // adress of RTC where data is to be written
    
     UCB0TXBUF = 0x43;        // data = 43 second
        

     // stop condition I2C
    UCB0CTL1 |= UCTXSTP;

    UCB0CTL1 &= ~UCTR;                      // I2C RX
    UCB0CTL1 |= UCTXSTT;                    // I2C start condition
            while(1)
            {
        UCB0I2CSA = 0xD0+0x01;     // wait till reading from RTC
            }

 

awaiting reply

 

thanks,

rohit

  • Hi rohit,

    there is something wrong in your slave address, you should set UCB0I2CSA to a 7 bit value. Seems like what you are trying to do is append to the 7 bit address the R/W bit, but this is automatically done by the microcontroller.

    So, your code should be both in transmission and reception:

    UCB0I2CSA = 0x68;                         // Set slave address

    regards,

    Marco

  • Thank u, but i did not bet u,

    The RTC used has the slave adress 1101000(7 bits), so and the first action is to write(Tx) so it becomes 11010000 i.e why UCB0I2CSA is 0x60. i did not get u why u have said 68,

    by the way start condition is executing, but now when i move the data to UCB0TXBUF the UCB0TXIFG becomes low but then it remains permanantly low, i.e data is not transfering and also i am not geting back the acknowledgment.

    anothere question is, when i write in slave adress , does this automaticaly tranfers to slave for authentication or i need to again transfer it using UCB0TXBUF ?

     

    please reply,

     

    thanks

    rohit

**Attention** This is a public forum