Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

CCS/MSP430G2553: Trying I2C with the MSP430, and I'm running into some very strange problems

Part Number: MSP430G2553

Tool/software: Code Composer Studio

I'm trying to learn I2C communications with an accelerometer sensor, the MPU6050, and the MSP430. However, I'm running into a strange issue with just trying to transmit my start command. My code is the following

#include <msp430.h>
#define SCL BIT6
#define SDA BIT7


unsigned char Read(char);
void ChangeAddr(char);
void SetUART(void);
void UARTSendArray(unsigned char *TxArray, unsigned char ArrayLength);

static volatile int INT_ENABLE;
/*
* main.c
*/
int main(void) {
unsigned char AccelData;

WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

DCOCTL = CALDCO_16MHZ;
BCSCTL1 = CALBC1_16MHZ;

//BCSCTL1=CALBC1_8MHZ;
//DCOCTL=CALDCO_8MHZ;
//BCSCTL2|=DIVS_2; //SMCLK divider = 4;


UCB0CTL0 |= UCMST + UCMODE1 + UCMODE0 + UCSYNC;
UCB0CTL1 |= UCSSEL0 + UCSSEL1;

UCB0BR0 = 160;
UCB0BR1 = 0;

UCB0I2CSA = 0x68;

P1SEL |= SCL + SDA;
P1SEL2 |= SCL + SDA;
// the ado pin on the mpu6050 will be tied low for x68, otherwise if 1, then x69
UCB0CTL1 &= ~UCSWRST;

//SetUART();


while(1) {
UCB0CTL1 |= UCTXSTT + UCTR;
}

}

 

I've used this example from this link, https://e2e.ti.com/support/microcontrollers/msp430/f/166/t/144890,  for both my code and to try and match my waveform. . My code in the above example is simply to repeat the start command to view it on the scope, However mine generally ends up looking like the below.

 

I'm not sure what I'm doing wrong and alot of the code from TI examples I use and modify end up looking very similar to this. I'd greatly appreciate any insight on what I could be doing wrong. Thanks very much

 

  • Would you be able to evaluate the TI code examples before making your changes? What resistance value are your I2C pull-ups? Your test case is slightly odd, you should at least be ensuring that the previous start condition was sent before sending the next (repeated start). There are also multiple MSP430 MPU6050 code examples/project provided by the online community that you can reference.

    Regards,
    Ryan

**Attention** This is a public forum