12F675 ADC Problem
I'm trying to use ADC (10 bit) of PIC 12F675. I prepared a test code which turns on a led if the voltage in the analog input pin is higher than 3.8V and turns off if lower. Test code runs in a while loop continuously. A voltage source is directly connected to analog input pin and ground. I change the output voltage to test the ADC code. It works fine when I increase the voltage. Nothing happens(led is off) until it reaches 3.8V and then the led turns on.
The problem is that when I decrease the voltage led stays on until analog input voltage is below 3.5V. Once it is off it won't turn on until voltage reaches 3.8V. And again it is on until voltage is below 3.5V.
Supply voltage of the microcontroller is 5V. ADC is 10-bit. In my test I noticed that if the value of the resistor in series with the led is increased, "turn on" and "turn off" voltage difference decreases. For example it is on above 3.8V and off below 3.7V. If I connect 10K resistor voltage difference is nearly 0.3V.