Hi all! Have been trying to do a 10bit A/D conversion using a PIC16f876 but something strange happens...I have a working circuit and send the result through RS232 to my pc...I use a potentiometer with the two ends connected at Vdd and GND and the other end is connected to PORTA.0...Look at some measurements i did..The first values are from my digital multimeter and the second values are the decimal value of the a/d conversion variable...
5V --> 1023 (5v)
4V --> 785 (3.8v)
3V --> 552 (2.7v)
2V --> 300 (1.47v)
1v --> 65 (0.3v)
0v --> 0 (0v)
As you can see the A/D conversion can show the max and minimum values but it is lost in between..
Here is my code(reference votlage is set to Vdd = 5V):
DEFINE HSER_RCSTA 90h '
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 129
DEFINE HSER_CLROERR 1
DEFINE OSC 20
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 2 (tried 3 but didn;t work)
DEFINE ADC_SAMPLEUS 50 (tried increasing but didn;t work)
adcdata var WORD
trisa = %11111111
ADCON1 = %10000010
main:
ADCIN 0, ADCDATA
hserout [dec ADCDATA ,13]
pause 1000
goto main
What can be wrong?? I 've also tried a version where you manual set the conversion to start and checking the bit2 of adcon0 etc etc but same results...
Also tried with 3.3V reference voltage at PortA but still no luck...
Bookmarks