Hi Mark,
> seeing inputs being made when they are not <
Inputs will act flakey if left floating. If you have internal or external pull-ups or pull-downs, and your switches reverse the pull-up/pull-down logic when made, inputs should behave normally.
Without internal or external pull-ups/pull-downs, reading a floating input pin will return unexpected results.
< is it OK to keep switching on and off the ADC? <
It shouldn't matter if you switch the A/D module on or off, but you're not switching off the A/D module by writing to ADCON1. ADCON0.0 turns on/off the A/D converter module.
ADCON0.0 = ADON: A/D On bit
ADCON0.0=0 ' A/D converter module is shut-off
ADCON0.0=1 ' A/D converter module is operating
ADCON1 is for the A/D Conversion Clock Select bits, A/D Result Format Select, A/D Port Configuration Control bits, and A/D Voltage Reference Select bit.
If your external circuit maintains analog signals on your A/D inputs, I wouldn't recommend you set these A/D inputs to digital by writing 11101111 to ADCON1.
Analog levels on any pin that is defined as a digital input including the AN15:AN0 pins, may cause the input buffer to consume current that is out of the devices specification which could lead to odd problems depending on several factors.
> do I need to add wait statements after switching it off <
I have never experienced any problems turning an A/D module on or off without wait periods afterwards, but you do need to wait for the required acquisition time after turning the A/D module on via ADCON0.0 before starting the conversion via ADCON0.2.
> I disable the ADC with an ADCON1=11101111 after doing a read, is this correct? <
No. If you need to conserve power you can turn off the A/D module to reduce power consumption by clearing ADCON0.0, but you definitely don't want to make analog input pins "digital " inputs by ADCON1=11101111 with external analog signals connected to them.




Bookmarks