I need to work on my bit operations, I'm hitting a rather silly mental block
8 MSBs:
if I just assign the 10bit number to an 8 bit register, ie CCPR1L = MyTenBitNumber, do the last 2 bits get
safely dropped or do they overflow somewhere?
2 LSBs:
Consider the following code:
unsigned int uiLSB;
uiLSB = MyTenBitNumber; // uiLSB = 1000110011 for example
uiLSB &= 512; // uiLSB now equals b'1000000000', only keeping the 2 LSBs.
uiLSB = uiLSB >> 4; // uiLSB now equals b'0000100000',
aka 32
This should leave me with either 16, 32 or 48, reflecting the three possible combinations for bits 4 & 5 - it is 32 in the example above.
The reason I did this was to give myself an 8 bit number with the original LSBs now lined up with bits 4 & 5 in CCP1CON, as in the back of my mind I was thinking that XOR would let me add these into the target register. I then remembered how XOR works and realised this wasn't going to happen
If CCP1CON = 00011100, how do I neatly change this to 00101100, other than checking and changing the two bits individually?