It looks like you may have already solved the issue, but there is a more efficient way to split a 16-bit value over two ports. Just by using a bit of clever C memory management.
By using a struct inside a union, you can read/write a 16-bit value as a whole. But you can also read/write the exact same value as if it is split into two separate 8-bit integers.
It should look something a little like this...
Code:
union {
uint16_t value;
struct {
uint8_t lsb;
uint8_t msb;
};
} convertedValue;
int main(void) {
convertedValue.value = ADCC_GetSingleConversion(channel_ANA0); //Lets say convertedValue.value == 0xBEEF
LATC = convertedValue.msb; // this value would be 0xBE
LATB = convertedValue.lsb; // and this value would be 0xEF
}
The beauty about this method is that you can extend the union and access each bit individually if you wanted.
Be80be, x = y & 3, or in binary, x = y & 0b00000011 is an AND operation, normally called a bit mask in this case. Essentially if x is one of your ports, the maximum you're going to see on the port is pins 1 and 2 turned on.
I agree with mike.. Bitmasking a port with & 2 would allow only pin 2 on the port to flash (0b00000010)
The is only 10 bit I'm using PORTC 0 to 7 for the first 8 bit's and PORTB 0 to 1 for the last 2
I'd need to mask off 2 to 7 on PORTB I don't no much about this stuff But I'm learning.
Yep!!
Again I'm putting out untested code... But!! It was nearly 11pm and it did show Burt another way!! The Union is the other way, but Danny!! You do not need the embedded struct... A simple union will suffice..