I am trying to understand how adc works and also trying to make an ADC function
If the result is Right justified can anyone describe how the adc value stored??
And IS ADRES is a valid MCU register??
If the adc value taken is 563. In binary it is 1101010101.
Then the lower 8 bit stored in ADRESL register (8 bit register).
That is 01010101 goes to ADRESL register (8 bit register).
and the upper 2 bit i.e 11 goes to bit0 and bit1 of ADRESL respectively
but is some example of other compiler (like mikro c , mplab ) they always use a step:
Code:
(ADRESH<<8) | ADRESL ;
and stored this value in a variable (16 bit or 2 byte variable required).
My question is why (ADRESH << 8) is step is required
if the contain of ADRESH is 00000011; then after shifting 8 times to the left it becomes 00000000 and if we bit wise ORED with ADRESL it becomes
ADRESH -> 00000000
ADRESL -> 00110011 ( BITWISE OR operation)
-------------------------
00110011 ???( a 8 bit number but it should be a 10 bit )
Here is the example of MPLAB XC8
Can someone show me the bitwise operation?
for example
ADRESH = 0b00000011;
ADRESL = 0b00110011;
ADD_VALUE = (ADRESH<<8) | ADRESL ;
And is ADRES is a valid register??
If the result is Right justified can anyone describe how the adc value stored??
And IS ADRES is a valid MCU register??
If the adc value taken is 563. In binary it is 1101010101.
Then the lower 8 bit stored in ADRESL register (8 bit register).
That is 01010101 goes to ADRESL register (8 bit register).
and the upper 2 bit i.e 11 goes to bit0 and bit1 of ADRESL respectively
but is some example of other compiler (like mikro c , mplab ) they always use a step:
Code:
(ADRESH<<8) | ADRESL ;
and stored this value in a variable (16 bit or 2 byte variable required).
My question is why (ADRESH << 8) is step is required
if the contain of ADRESH is 00000011; then after shifting 8 times to the left it becomes 00000000 and if we bit wise ORED with ADRESL it becomes
ADRESH -> 00000000
ADRESL -> 00110011 ( BITWISE OR operation)
-------------------------
00110011 ???( a 8 bit number but it should be a 10 bit )
Here is the example of MPLAB XC8
Can someone show me the bitwise operation?
for example
ADRESH = 0b00000011;
ADRESL = 0b00110011;
ADD_VALUE = (ADRESH<<8) | ADRESL ;
And is ADRES is a valid register??