I don't see where you are configuring the analog select register ANSEL.
By not explicitly setting the value of this register the PIC is using the default value, which might be enabling some pins as analog.
Check the Datasheet to verify how you want them set and make sure you add the appropriate ANSEL = xxx statement to the beginning of your program.
That may be causing you a problem.
I have found it is usually a good idea to check and set the registers for all of the hardware modules.
Might be worth checking.
Bookmarks