Other Parts Discussed in Thread: MSP430G2553
Hello!
I've deliberately named my question like that - I know that it's already been asked but the answers don't help me at all.
I have a custom board with MSP430G2553 and an I2C real-time clock M41T81S. I program it through the MSP-EXP430G2 launch pad. I use TEST & RST (pin 16, 17) & GND for programming. I have NO pull-ups. I use the internal ones. I use external Vdd.
My communication is stuck at while(UCB0CTL1 & UCTXSTT){ } and doesn't go on. Can please someone give me any ideas? Here's the code:
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD;
// Set DCO to 16MHz
BCSCTL1 = CALBC1_16MHZ;
DCOCTL = CALDCO_16MHZ;
BCSCTL2 &= ~SELS; //SMCLK = DCOCLK
P1SEL |= 0xC0;
P1SEL2|= 0xC0;
P1REN |= 0xC0;
P1OUT |= 0xC0;
UCB0CTL1 |= UCSWRST;
UCB0CTL0 = UCMST+UCMODE_3+UCSYNC;
UCB0CTL1 = UCSSEL_2+UCSWRST;
UCB0BR0 = 160; // fSCL = SMCLK/160 = ~100kbps
UCB0BR1 = 0;
UCB0I2CSA = 0x68;
UCB0CTL1 &= ~UCSWRST;
while (1)
{
UCB0CTL1 |= UCTR;
UCB0CTL1 |= UCTXSTT;
while (UCB0CTL1 & UCTXSTT){ }
UCB0TXBUF = 0x02;
while(IFG2 & UCB0TXIFG){ }
UCB0CTL1 |= UCTXSTP;
while (UCB0CTL1 & UCTXSTT){ }
}
}
Thanks in advance!