morelius21 0 Posted March 29, 2014 Share Posted March 29, 2014 Hello, 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? Thanks Quote Link to post Share on other sites
KatiePier 73 Posted April 4, 2014 Share Posted April 4, 2014 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 or 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! Regards, Katie tripwire and spirilis 2 Quote Link to post Share on other sites
morelius21 0 Posted April 5, 2014 Author Share Posted April 5, 2014 Hi, i'm very appreciate your response. Ok i understand it and i will use this form of define. Is true that this method is useful than the another. Thanks Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.