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 problem slaa208a

Other Parts Discussed in Thread: MSP430G2553

Hi!

I looking for some advanced persons help!

I try to communicate to at24c128c EEPROM with msp430g2553 (launchpad).

I made the pull-up resistors as it is required and some of the mspware demos do some traffic on the lines, but those not for eeprom.

So, i took the slaa208 source and import it into a css6 project to see what it can do.

Actually it seems nothing!

There was a little error at compilation, but after correction it was looking fine.

When i started the program it seems stalled.

Then i hooked it up with oscilloscope, and all the lines was quite!

When i checked the debug, it seems it did not finished the first write cycle. It was hanging at "i2c stop condition"
 in this function.

/*----------------------------------------------------------------------------*/
// Description:
//   Byte Write Operation. The communication via the I2C bus with an EEPROM
//   (2465) is realized. A data byte is written into a user defined address.
/*----------------------------------------------------------------------------*/
void EEPROM_ByteWrite(unsigned int Address, unsigned char Data)
{
  unsigned char adr_hi;
  unsigned char adr_lo;
 
  while (UCB0STAT & UCBUSY);                // wait until I2C module has
                                            // finished all operations.
 
  adr_hi = Address >> 8;                    // calculate high byte
  adr_lo = Address & 0xFF;                  // and low byte of address
 
  I2CBufferArray[2] = adr_hi;               // Low byte address.
  I2CBufferArray[1] = adr_lo;               // High byte address.
  I2CBufferArray[0] = Data;
  PtrTransmit = 2;                          // set I2CBufferArray Pointer
 
  I2CWriteInit();
  UCB0CTL1 |= UCTXSTT;                      // start condition generation
                                            // => I2C communication is started
  __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0 w/ interrupts
  UCB0CTL1 |= UCTXSTP;                      // I2C stop condition
  while(UCB0CTL1 & UCTXSTP);                // Ensure stop condition got sent
}

If you have any idea what happened, i would be glade to hear!

  • I am not the expert but I suggest you to check the few things first please make sure your slave address for eeprom is correct  and second thing you have turn on the TX and RX interrupts during initialization. and suggest to post your ISR routine if possible I think it stuck because no successful byte transfer with eeprom so  UCTXSTP bit not cleared and you stuck there

  • Hi!

    Thank you for your answer!

    The slave address is correct. The code is exactly the same as the slaa208a.zip contains except the that i have removed the following lines:

    #if __VER__ < 200
        interrupt [USCIAB0TX_VECTOR] void TX_ISR_I2C(void)
    #else

    #endif

    Because the compiler gave an error.

    After many hours of extensive investigation, i find that the UCTXSTT and UCTXSTP bits are remain set after the start and stop condition sent!

    Is that possible?

  • #pragma vector=USART0TX_VECTOR
    __interrupt void ISR_I2C(void)
    try this vector for your ISR you need to specify the interrupt vector ...

    http://e2e.ti.com/support/microcontrollers/msp430/f/166/t/198590

    look at this above link..

  • SRY. I was not enough specific!
    I am trying to use the USCI example. I am not even sure the USART code compatible with the msp430g2553.
    At least the CSS 6 gave me tons of errors during compilation.

  • Dose it work with USCI example? if not then what is the problem you having please tell.

  • Hi Peter,

    Did you change the SDA/SCL pins? The pins are different in F227x and G255x.
    What value are you using for the external pull-ups? These depend on the capacitance of your bus, but something like 1K-3.3K should be OK.

    I saw that you removed some lines, but I assume you left the following lines, correct?
    #pragma vector=USCIAB0TX_VECTOR
    __interrupt void TX_ISR_I2C(void)

    After that, it would be good to check the SDA/SCL lines with an oscilloscope to check if the MSP430 is sending the START condition properly; check if the slave is ACK'ing its address, check if the MSP430 is going to the ISR by setting an interrupt, etc.

    Regards,
    Luis R
  • BTW, please note that the code sets the GPIO functionality in InitI2C, and it uses the following definitions: I2C_PORT_SEL, SDA_PIN, SCL_PIN.

    However, for the G2xx3 you need to write both the P1SEL and P1SEL2 registers.

    Regards.
    Luis

**Attention** This is a public forum