Hi everyone,
I have an assembly project that was developed using 10-bit Adc PIC. However, because the PIC is not available at this time, so we want to use a 12 bit PIC184423F ADC. Obviously, this will not be a straight swap to make the existing firmware work. I know that the resolution of the step size for a 12 bit is 1.22, different than the step size of 4.88 of the 10 bit. Now shifting right will be the same as dividing the ADC result, and thus this will give us the result like if we were using a 10 bit ADC. There's this 16-bit operation from this author 16 Bit Operations Chuck McManis. that contains a macro LSR16 to rotate a 16 bit right. However, the problem that I don't understand clearly is that the PIC184420f only holds an 8-bit registers, so how will be possible to combine the adresh and adresl into a single 16-bit register and shift it, if the pic18f is only for 8-bit register. Please I need help to find a solution to the problem of how to make the 12 bit ADC result into a 10-bit result. Below there's a simple example where I'm just saving the adresh and adresl into two 8 bit register. I don't seem to understand how to shift the ADC result to make 10 bit.
Adc
movlw 0x9D
movwf ADCON2
movlw 0x08
movwf ADCON0
bsf ADCON0,GO
wait
btfsc ADCON0,GO
bra wait
movff ADRESL,low
movff ADRESH,high
I have an assembly project that was developed using 10-bit Adc PIC. However, because the PIC is not available at this time, so we want to use a 12 bit PIC184423F ADC. Obviously, this will not be a straight swap to make the existing firmware work. I know that the resolution of the step size for a 12 bit is 1.22, different than the step size of 4.88 of the 10 bit. Now shifting right will be the same as dividing the ADC result, and thus this will give us the result like if we were using a 10 bit ADC. There's this 16-bit operation from this author 16 Bit Operations Chuck McManis. that contains a macro LSR16 to rotate a 16 bit right. However, the problem that I don't understand clearly is that the PIC184420f only holds an 8-bit registers, so how will be possible to combine the adresh and adresl into a single 16-bit register and shift it, if the pic18f is only for 8-bit register. Please I need help to find a solution to the problem of how to make the 12 bit ADC result into a 10-bit result. Below there's a simple example where I'm just saving the adresh and adresl into two 8 bit register. I don't seem to understand how to shift the ADC result to make 10 bit.
Adc
movlw 0x9D
movwf ADCON2
movlw 0x08
movwf ADCON0
bsf ADCON0,GO
wait
btfsc ADCON0,GO
bra wait
movff ADRESL,low
movff ADRESH,high