In the sample A to D program, when obtaining the temperature, ADRESH is divided by 2. The result is that the temperature value is half of what it actually is. Is there any reason why ADRESH is divided by 2 or did they just mean to mask out the last bit (ADRESH & ~1)
I’m sorry, but I can’t locate where the ADRESH is divided by 2 in the code.
[code]unsigned char ntc (void)
{
ADCON0 = 0b10000001; // Analog-to-Digital FOSC/32, Channel 0 (RA0),
// input from NTC
delay(); // Acquisition delay
ADCON0bits.GO = 1; // start conversion
while (ADCON0bits.GO); // wait until done
return ADRESH;
}[/code]
Somehow the version I have has return ADRESH << 1
Anyway, looks like that is incorrect. Thanks.
OK. It seems that you have a modified version.
Here you can download the original EDU10 examples:
velleman.eu/downloads/files/ … /edu10.zip