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.
Part Number: MSP430F5529
#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.
Please see the following application note for debugging I2C issues. Solutions to Common eUSCI and USCI Serial Communication Issues on MSP430 MCUs
I would also suggest starting from one of our I2C code examples. From your code above a few things are amiss. First, you enable the TX interrupt, but do not have an ISR. This means you will jump to a trap ISR and do nothing. It also means you are not filling the TXBUFF so nothing is sent on the I2C lines. In addition, If you ever do break out of your while statement, your program will end and do nothing else. This means you would send one byte and then do nothing. You need an application loop [while(1)] to ensure the device keeps performing.
For other I2C debug efforts, please see the application report linked to above.
Search E2E! Your questions may already be answered!
TI Cloud Tools MSP Product Page
In reply to Jace H:
Thank you a lot! I checked that AP and I already have tried these solutions they didn't work. The code jumped into a trap ISR sometimes, but just if I delete that while and continue running my code. I don't understand why didn't it happen in MSP430G2553? I wasn't aware of ISR, although I couldn't correct that despite all my efforts.
I found the I2C code examples but I can't run them either, it gets stuck in:
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, enable interrupts
I tried to adapt those examples to my code, but I didn't succeed so I try to run the examples for itself they didn't work.
I pick the examples from here, the windows version and the I2C, then I selected the ones that said "This is the MASTER CODE.", for read or write one or multiple bytes.
My code actually continues, I send the start bit and read data, etc. I just past the code before the loop where it stops. If I solve it there the rest of it should work fine since it worked in MSP43G2553 system.
I hope you can help me with it, this is my master's project and I am behind the deadline with all those stepbacks.
Thank you so much for your time!
Hello! Could someone help me with this?
In reply to Gabriela Costa:
In reply to Clemens Ladisch:
Why aren't the ports correct? What is missing or wrong? Can you please be more specific?About the SDA_PIN/SCL_PIN, they are carrect for P3.0 and 3.1 (BIT0/BIT1 = 0x00 / 0x01).
msp430f5529.h uses alternative facts:
#define BIT0 (0x0001)
#define BIT1 (0x0002)
#define BIT2 (0x0004)
As Jace already told you, you get an interrupt because you enabled the interrupt.
Start with a super-simple program that does nothing but doing a one-byte I²C transaction.
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.