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