Hi there ppl.
working with a P18F4331 and doing A/D convertion. I want to display the result on PORTB but as you know P18f4331 is a 10bit A/D converter and PortB only has 8Bits
If A/D is justified right
char x,y;
int z;
x = ADRESL; //low byte
y = ADRESH; // high byte
and i have the following "nested if " ( deviding 10bit value into the 8bits of portB)
if(z <= 128)
PORTB = 0x01;
else if(z <= 256)
PORTB = 0X03;
else if(z <= 384)
PORTB = 0x07;
else if(z <= 512)
PORTB = 0x0f;
else if(z <= 640)
PORTB = 0x1f;
else if(z <= 768)
PORTB = 0x3f;
else if(z <= 896)
PORTB = 0x7f;
else if(z < 896)
PORTB = 0xff;
how do i define z where z = Highbyte,lowbyte combind. Basically how do i make a 10 bit value form 2 8bit values x & y
working with a P18F4331 and doing A/D convertion. I want to display the result on PORTB but as you know P18f4331 is a 10bit A/D converter and PortB only has 8Bits
If A/D is justified right
char x,y;
int z;
x = ADRESL; //low byte
y = ADRESH; // high byte
and i have the following "nested if " ( deviding 10bit value into the 8bits of portB)
if(z <= 128)
PORTB = 0x01;
else if(z <= 256)
PORTB = 0X03;
else if(z <= 384)
PORTB = 0x07;
else if(z <= 512)
PORTB = 0x0f;
else if(z <= 640)
PORTB = 0x1f;
else if(z <= 768)
PORTB = 0x3f;
else if(z <= 896)
PORTB = 0x7f;
else if(z < 896)
PORTB = 0xff;
how do i define z where z = Highbyte,lowbyte combind. Basically how do i make a 10 bit value form 2 8bit values x & y