Other Parts Discussed in Thread: MSP430G2553, MSP-FET
#define SLAVE_ADDRESS 0x0D /**< Address to AD5933. */ #define BAUD_RATE 12 /**< Baud Rate value. */ #define SDA_PIN 0x00 // msp430F5529 UCB0SDA pin #define SCL_PIN 0x01 // msp430F5529 UCB0SCL pin P1DIR |= BIT1; P1OUT |= BIT1; P1OUT ^= (BIT1); //turn on LED (is turned off when all data for initialization was send) P3REN |= SDA_PIN + SCL_PIN; P3OUT |= SDA_PIN + SCL_PIN; P3SEL |= SDA_PIN + SCL_PIN; // Assign I2C pins to USCI_B0 UCB0CTL1 |= UCSWRST; // Enable SW reset UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset UCB0BR0 = BAUD_RATE; // set prescaler UCB0BR1 = 0; UCB0I2CSA = SLAVE_ADDRESS; // Set slave address UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation //UCB0IE = UCNACKIE; //tried with and without this line, there isn't a difference UCB0IE |= UCTXIE; // Enable TX ready interrupt P1OUT ^= (BIT1); //turn off LED while (UCB0STAT & UCBBUSY) ;
That is my code. I know that my board works because the LED blinks fine, but I always get stuck in that last while loop.
This code is adapted from MSP430G2553 communication with AD5933 as well, where it worked fine. I did all the necessary ports and pins changes according to the datasheet.
One other difference between this and the other system is that now I am using a MSP-FET Flash Emulation Tool plus a micro UBS to power, instead of the mini USB port. But I don't know how this may or may not affect my code.
It seems that the STAT of the MSP never changes and the communication isn't established. Can someone help me with it? I don't know what is wrong with my initialization. Maybe the problem is with the interrupts? What should I do?
Thank you all in advance for trying to help me.