PIC16F77 ADC not producing 0v result with 0v input

I've set up a PIC16F77 to repeatedly sample an analogue DC signal. The problem is when I apply a 0v signal, the ADC does not read as 0x00. It's an 8-bit ADC and at 0v reads about 0x05 - 0x06. (I'm using the Vref pin for scaling, and have set it to 2.55V).

What I have done to try to fix the issue:

• A well regulated 5v power supply
• Smoothing capacitors on the Vref pin
• Smoothing capacitors on the power supply
• Tied all other analogue inputs to ground
• Increased the acquisition delay to about 40us (recommended is 16us)
• The signal to the analogue inputs is in the order of a few ohms - the recommended is less than 10k

The datasheet says +/- 1LSB should be possible, and I'm mystified. Can I expect better from this PIC? And how can it be achieved?

Thanks!

• Do you get that reading with the ADC input grounded? – alexan_e Jan 30 '14 at 11:20
• Are you breadboarding this? If so, could you share a detailed photo of your connection? – abdullah kahraman Jan 30 '14 at 11:25
• Can you try taking readings with the ADC input connected directly to analog ground with a short wire? I know you say you have 0V signal but that's not quite the same. – Joe Hass Jan 30 '14 at 11:27
• Yes that is with the analogue input going to ground with a short wire on a breadboard ... I will tidy it up and take a photo – CL22 Jan 30 '14 at 12:19
• Do you have a schematic? My guess would be that your ADC pin is floating, i.e you have to choose a proper pull down resistor if you need it to read 0x00. – chwi Feb 5 '14 at 9:29

The problem disappeared, and I'm not entirely sure why, as I have not been able to replicate the problem I had, once it disappeared! But I made the following changes:

1. Replaced the uC. Perhaps the other one was slightly damaged
2. Changed configuration of ADC/Digital ports as below:

To quote the datasheet on "Configuring analog port pins" section:

Analog levels on any pin that is defined as a digital input, but not as an analog input, may cause the digital input buffer to consume current that is out of the device's specifications.

Both before, and after the problem, I had set bits PCFG2:PCFG00 to 011 (ADCON1 register) which sets:

• RA0, RA1, RA2, RA5 pins to analogue inputs
• RA3 as the Vref pin
• RE0, RE1, RE2 as digital IO.

I had tied RA0, RA1, RA2 and RA5 to ground to test if they were outputting 0x00. Before the changes were not 0x00, but after the changes, were 0x00.

The problem/solution:

I had left RE0, RE1, and RE2 as digital inputs rather than outputs. I left them floating. This may have caused problems as described in the quoted paragraph (above), possibly damaging the chip. In other words, I had initially set TRISE register to 00000111.

I believe setting TRISE to 00000000 instead may be what fixed the issue. Perhaps a second solution would have been to simply tie RE0, RE1 and RE2 to ground or +5v.