Connect with us

Issue with I2C (MSP430F1612)

Discussion in 'Electronic Design' started by Hari, Sep 26, 2007.

Scroll to continue with content
  1. Hari

    Hari Guest


    I am using MSP430F1612 in my design and trying to communicate with
    external fuel gauge IC.
    Any body tried Repeated start by using software counter (I2CRM =
    1)for Data tx/rx.

    Clock: 8MHz (Configured as 4MHz for SMCLK)

    I2Cinit as follows

    /*Enable I2C module operation (not using them as GPIO) */
    /* To set UART0 module to operate in I2C mode */
    U0CTL |= I2C + SYNC;
    /* I2C operation is disabled */
    U0CTL &= ~I2CEN;
    /* 7 bit addressing mode */
    U0CTL &= ~XA;
    /* Master mode selection*/
    U0CTL |= MST;
    /* Selection of SMCLK */
    I2CTCTL |= I2CSSEL1;
    /* Prescaler Reg */
    I2CPSC = 0x00;
    /* I2C Shift Clock High Reg*/
    I2CSCLH = I2C_CLK_HIGH_REG_SEL; //0x12
    /* I2C Shift Clock Low Reg*/
    I2CSCLL = I2C_CLK_LOW_REG_SEL; //0x12
    /* I2C Own 7 bit address */
    /* Select Byte Mode */
    I2CTCTL &= ~I2CWORD;
    /* Number of bytes transmitted is controlled by the s/w
    I2CTCTL |= I2CRM;
    /* Enable I2C*/
    U0CTL |= I2CEN;
    /* Idle condition - No Start*/
    I2CTCTL &= ~I2CSTT ;
    /* Idle condition - No Stop */
    I2CTCTL &= ~I2CSTP;

    While writing and Reading these steps will be performed

    /* Disable I2C*/
    U0CTL &= ~I2CEN;
    /* Transmit mode */
    I2CTCTL |= I2CTRX ; // I2CTCTL &= ~I2CTRX ; for receive mode
    /* Slave address 0 to 6 bits */
    I2CSA = ucSlaveAddr>>1;
    /* Put the I2C in Byte mode*/
    I2CDCTL |= I2CSBD;
    /* Enable I2C*/
    U0CTL |= I2CEN;
    /* Master mode selection*/
    U0CTL |= MST;
    /* Initiate Start */
    I2CTCTL |= I2CSTT;

    if ((I2CIFG & NACKIFG))
    return ERR_WRITE;

    then read or write the bits depends on Tx / Rx operation, if TXRDYIFG
    or RXRDYIFG is ready

    and sent the stop bit (only for Read).

    Timer interrupts are used for time out conditions. (No interrupts were
    used for I2C module)

    This is code is working once in a while, but there is no consistency.
    few things i got from Errata but its not clear where i can use
    repeated start when I2CRM = 1.

    In my code I2CWrite will be called in I2CRead so repeated start will
    occur (start again before sending stop). any suggestions or

    Observations in I2C Fail condition:

    Controller is sending only the address of the device and ACK from
    device, and not able to transmit other data after that both the SCL
    and SDA are pulled high .
  2. might be due to noise on the lines !
    use some shielded cabling and try . ....
    else pull down resisitor of 1meg may be connected and experimented at
    different places.
    mail me with prototypt pics...
    kaushik 899 @
  3. Ben Jackson

    Ben Jackson Guest

    What are you talking to? Does it support that clock? Maybe I2C is
    more standardized, but with SPI you've got to check every device you
    want to talk to because they might all be different.
  4. Hari

    Hari Guest

    Let me make it clear..

    8MHz is Main clock frequency... its not SCL clock.

    SCL is configured as 100KHz.

    yesterday i performed few more test on the board and i found that SCL
    is varying. (Change in clock frequency detected)

    With Cheers
    Dig MSP430
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day