Jump to content

How to define a pin in Code composer studio

Recommended Posts



I'm total newbie and i have my first problem: 

I try define a pin in my launchpad with msp430g2553 but i don't get it.


In IAR i know this:

#define LCD_4   P1OUT_bit.P1OUT_0


But in code composer don't work and i think it's because i don't use io430.h  because there isn't in CCS. I use the msp430.h library.


can somebody tell me pleaso how can i define the pin in CCS?



Link to post
Share on other sites

Hi @@morelius21,


CCS doesn't really use the PxOUTbit.PxOUT format - I actually do not see many people use this format even with IAR because I think it is a bit inefficient if you want to set up a whole port at once.


Instead I usually do something like this:

P1OUT |= BIT0; //to set the bit


P1OUT &= ~BIT0; //to clear the bit

If I want to make a mnemonic to make this easier to read what pins go with what functions on my board, I would do something like this:

#define LCD_OUT   P1OUT
#define LCD_4     BIT0

Then you can use statements like these, which will evaluate the same as the code I put before:

LCD_OUT |= LCD_4; //set the bit
LCD_OUT &= ~LCD_4; //clear the bit

What's nice about using these kind of operations is that you can set or clear multiple bits at once too:

#define LCD_OUT   P1OUT
#define LCD_4     BIT0
#define LCD_5     BIT1
LCD_OUT |= LCD_4 + LCD_5;
LCD_OUT &= ~(LCD_4 + LCD_5);

There are a whole bunch of other ways you can do this too - it's all personal preference really.

Hope this gives you some ideas!




Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...