I have written code for ADC interfacing for mega8. I put ADC subroutines in separate file "ADC_routines_m8.c" & properly added to project. Put function prototypes in header & included in main too. I am using 10 bits of resolution with default Right-adjusted result.
Now, the problem I am getting is that whenever I call the function
ADC_convert(channel); //channel:0..5
which is supposed to return 16 bit ADC value, It only returns 8 bit value! even though the return type is 16 bit declared everywhere.
Forget the ADC, even if I write:
return 0x1FE; , it prints only 0xFE on the LCD(in main).
The prob is not with the ADC, but with the return type. If I put the file's contents (& prototypes) in main, it works fine (10bit ADC or 0x1FE are printed).
What can be wrong? Any help would be greatly appreciated.