# I2C Code Composer Studio example for MSP430G2553

I've been scouring the forums for a complete I2C implementation for MSP430G2553 using Code Composer Studio. All I can find are code snippets out of context or single byte examples.

I need to figure out how to do the following using Code Composer Studio 7x On an MSP430G2553 with I2C:

1. Write a byte of data to a specific register.
2. I need to do the above on 2 different I2C slaves.
3. I need to read MULTIPLE bytes from a single I2C slave.

I am new to controller programming. I have been programming in Windows for 20 years, but the low level controller programming is just one huge paradigm shift for me. If somebody could point me to a good example of the above 3 operations that will work in Code Composer Studio 7.x, I'd be very grateful.

I'm not asking somebody to write my code. I'm just having trouble with the basic concepts of how things work when programming controllers in CCS. I'm used to calling a function like:

SetPinMode(14,OUTPUT);


The above, when called would set pin 14 as an output pin.

However, when I see something in a TI example like:

UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC;   // I2C Master, synchronous mode


I can't make any sense of it. It's all abbreviated. Setting values is acting like calling a function. It's nice and compact, but for a guy used to calling a function with a meaningful name, it's incomprehensible... Looks like jibberish. I cannot read that code and make out what parts of it are doing what.. I'm thinking I might just need some 'Intro to Controller Programming' class to put me in the mode to decipher the above code.

It appears to me that the world of controller programming uses 'short-hand' instead of calling functions. I'm sure there's good reasons for this, but it's really hard to follow when first starting out. Any useful help with some explanations that would be useful to somebody like me who doesn't already know the answer would be greatly appreciated.

Anybody can say that they know how to do something. A truly gifted person can actually teach it to somebody that doesn't already know. That's what I'm asking for here. Or at least guide me to some source where the examples ARE spoon fed to start with. I just don't get the whole paradigm at this point, so it's hard for me to decipher...

• This is not a code writing service. Read chapter 17 of the User's Guide and TI's I²C examples. If you do not understand some particular piece of code, ask a specific question about that. – CL. Feb 28 '17 at 8:51
• You will find that all of those 'short hand' constants/macros/register names (usually) match the bit field names or registers listed in the User Guide (UG) and Datasheet (DS) for each uC. I learned quickly that whenever programming for a TI uC, one must have constant access to both the UG and DS. You must be familiar with the relevant sections of these docs before even starting to program. – Chris Knudsen Apr 3 '17 at 19:02