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.

CCS/MSP430G2553: I2C step by step

Part Number: MSP430G2553
Other Parts Discussed in Thread: MSP-FET

Tool/software: Code Composer Studio

Hi,

i´m playing around with the example codes atm and try to learn I2C.

I´m using the example codes "Master TX multiple bytes to MSP430 Slave" and "Slave RX multiple bytes from MSP430 Master" on my MSP430 Launchpads.

I was wondering if it´s possible to write a code without the I2C State Machine and go step by step to see what happens on the bus with an oscilloscope.

Is there maybe a code out there to see how that would work? (in C)

Maybe with these defines:

#define I2C_SLC_INIT  P1OUT&=~BIT6
#define I2C_SLC_HI  P1DIR&=~BIT6
#define I2C_SLC_LOW  P1DIR|=BIT6

#define I2C_SDA_INIT  P1OUT&=~BIT7
#define I2C_SDA_HI  P1DIR&=~BIT7
#define I2C_SDA_LOW  P1DIR|=BIT7

Thanks in advance and best regards

  • Hello Patrick,

    The code examples are an excellent place to start. In your code above, it appears that you're trying to control the pins as GPIOs rather than using the USCI I2C module functionality (I think this is what you referred to as the I2C state machine). The beauty of the I2C module is that it allows the CPU to be freed up and even go to sleep while the module transmits/receives. If the GPIOs are used, the CPU must be involved and the code/timing would be challenging. The user's guide should include more details about this module too.

    I would suggest using a logic analyzer to run the code and capture what's transmitted/received by the I2C interface. I prefer using it over an oscilloscope. Also, it would help to read through our popular Solutions to Common eUSCI and USCI Serial Communication Issues on MSP430™ MCUs application report.

    Happy coding and learning!

    Regards,

    James

    MSP Customer Applications

  • Hello James,

    thanks for the help! As you said, i want to do the conditions (for example the start condition) with the GPIOs. I only want to do this, to see what happens on the bus.

    After i´ve seen that, i will always use USCI I2C module. But for learning purposes and i would like to see a code which does exactly this.

    I know it would be alot of work, so i was wondering if there is such a code floating around :)

    Best Regards

    Patrick

  • The USCI I2C module handles the start conditions. I would recommend using a logic analyzer to view this, and you can use a debugger like the MSP-FET to step through the code. Actually, Chapter 17 in the User's Guide has some good explanation on how everything works plus some helpful timing diagrams.

    Regards,

    James

    MSP Customer Applications

**Attention** This is a public forum