TI E2E Community (Beta)
Welcome to the TI E2E (Engineer-to-Engineer) Community! We invite you to freely and openly interact with your peer Engineers, TI Engineers, and other experts in order to ask questions, share knowledge, explore ideas, and help solve problems.
More Search Options

I2C problems

rated by 0 users
Not Answered This post has 0 verified answers | 2 Replies | 2 Followers

Top 500 Contributor
17 Posts
Community Member
schneiderham posted on 3 Nov 2009 10:15 PM

Hi,

I am using a MSP430F5419 and a BQ272000 Battery fuel gauge using I2C.  I seem to be having troubles reliably communicating.  About 50% of the I2C interactions result in no acks; more specifically, it usually gets stuck in line (5) waiting for UCTXIFG.

Here is some simple code to read a register.  Note that the TimerWatchDog is used to avoid infinite loops.

1: SysTickStartTimer(&TimerWatchDog, 2);

2: while (UCB2CTL1 & UCTXSTP && !(SYSTICK_TIMER_ELAPSED(&TimerWatchDog)));             // Ensure last stop condition got sent

3:  UCB2CTL1 |= UCTR;

 4:  UCB2CTL1 |= UCTXSTT;             // I2C TX, start condition  

 5:  while (!(UCB2IFG & UCTXIFG) && !(SYSTICK_TIMER_ELAPSED(&TimerWatchDog)));           // When UCTXIFG is set the Start has been sent  

  6: UCB2TXBUF = Cmd;                        // Write Cmd  

  7: while (!(UCB2IFG & UCTXIFG) && !(SYSTICK_TIMER_ELAPSED(&TimerWatchDog)));           // Ensure Cmd is being sent  

  // Gointo Rx Mode

  8: UCB2CTL1 &= ~UCTR;

  9: UCB2CTL1 |= UCTXSTT;             // I2C RX, start condition

  10: while (UCB2CTL1 & UCTXSTT && !(SYSTICK_TIMER_ELAPSED(&TimerWatchDog)));             // Ensure start and address got sent

  11: UCB2CTL1 |= UCTXSTP;                // Generate I2C stop condition

  12: while (!(UCB2IFG & UCRXIFG) && !(SYSTICK_TIMER_ELAPSED(&TimerWatchDog)));           // Ensure Data Sent

  13: *Data = UCB2RXBUF;  

  14: __delay_cycles(I2C_ACCESS_DELAY*20);

  if( SYSTICK_TIMER_ELAPSED(&TimerWatchDog) )

  {

    return FALSE;

  }

  else

  {

    return TRUE;

  }

 

ANy suggestions.

All Replies

Not Ranked
14 Posts
Community Member

Hi Schneiderham,

 

I guess you need to send a STOP after the line 6, and then change to receive mode.

 

6: UCB2TXBUF = Cmd; // Write Cmd

UCB2CTL1 |= UCTXSTP

7:.....

 

Top 500 Contributor
17 Posts
Community Member

Thanks,

I tried but still doesn't help.  Also, the fuelgauge IC doesn't expect a stop until the end of the sequence.

Mat

Page 1 of 1 (3 items) |

ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". TI AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY TI. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.