This may seem like a simple or obvious answer; partly because it is and partly because I've looked everywhere and can't find what I'm looking for. I've yet to find something explaining what exactly some of these commands do and how they work. I'll list a few examples below:
P6DIR |= (BIT0) ;
So I know this makes pin 6.0 an output pin. But why? If I am reading correctly this statement can be written as P6DIR = P6DIR | BIT0 so you are ORing the register and the LSB together? How does this make it an output?
P6OUT|= (BIT0) ; // P6.0 High
This sets P6.0 to High, but how?
P6OUT&=~(BIT0); // P6.0 Low
This sets P6.0 to low, how and why?
I mean is there something in stone that explains why these operators work the way they do with these bits/registers?
Also the statement:
LCDCTL = (LCDSG0_3|LCD4MUX|LCDSON|LCDON);
I understand that the left hand operand is the LCD control register that consists of 8 bits. The selection of those bits apply to different functions(2/4mux, LCDon/off etc) and that the righthand identifiers correspond to the ones in the msp430xw42x.h file but I'm wondering if this was my first time looking at this stuff(I'm very new to this) how would I know what this statement is doing? I know what it does, but I am still unsure as to how it works and why it works the way it does.
Another example:
P5SEL = BIT4 | BIT3 | BIT2
I know this is setting bits 2,3,4 in the P5SEL register to 1 in order to pick it's secondary function of com0-com2 and not general i/o but why does this statement accomplish this.
Forgive me if my questions make no sense; I tried to be as clear as possible. I guess you could say I'm looking for a beginner's guide to programming the MSP430/coding techniques? Any questions please ask me.
Thanks,
Brock