Hey everyone,
for some reason when i send a repeated start i cant put it in reciever mode therefore setting the R/W bit high. After watching debug mode and trying to run to line (UCB0CTLW0 &= ~UCTR) it skips over it and keeps it high there causing the R/W bit to stay low. why won't it execute this command. See below for a picture of my waveforms i can make. Also see below for the waveform (figure 8) im trying to make. please help.
I2c sequence:
transmit start in write mode
send command
send repeated start in read mode
#include <msp430.h>
#define SLAVE_ADDRESS 0x5A
int Temperature;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P4DIR |= BIT0;
P4OUT |= BIT0;
P1SEL1 |= BIT6 + BIT7;
UCB0CTL1 |= UCSWRST;
UCB0CTLW0 |= UCSYNC + UCMODE_3 + UCSSEL_2+ UCMST;
UCB0TBCNT |= 0x0002;
UCB0BR0 = 0x001F;
UCB0BR1 = 0;
UCB0CTLW1 = 0;
UCB0CTLW0 &= ~UCTR;
//UCB0CTLW0 |= UCSLA10;
UCB0I2CSA = SLAVE_ADDRESS;
// UCB0CTLW0 = UCSSEL_2 //+ UCSWRST;
UCB0CTL1 &= ~UCSWRST;
// UCB0IE |= UCTXIE + UCRXIE + UCNACKIFG;
P1OUT &= ~BIT7;
// __delay_cycles(100000);
for (;;) {
P1OUT &= ~BIT7;
__delay_cycles(100000);
P1OUT |= BIT7;
P1SEL1 |= BIT7;
UCB0CTLW0 |= UCTR;
UCB0CTLW0 |= UCTXSTT;
while ((UCB0CTLW0 & UCTXSTT) != 0)
//{}
UCB0TXBUF = 0x0007;
while ((UCB0IFG & UCTXIFG) != 0)
UCB0CTLW0 &= ~UCTR;
UCB0CTLW0 |= UCTXSTT;
}
}