That's why I got an error when I tried to declare only AN2 to be analog input. Now it's getting more clear. It sound like I need more time to spend to understand this.No, many pins share both analog and digital functions. When they share each pin defaults to the analog function at power up, which keeps them safe no matter whatis connected to them. A digital only pin will similarly default to input again to keep things safe till the set up code is complete. As far as I know that is true across all microchip products.
Port d is digital only. Most pins of port b also have analog functions. AN 2 is on port a, and the only way to make it analog is to also make an 1 & 0 analog; see ADCON1 description.
You should be spending your time reading the spec sheet for your device. The documentation is very good and complete, so it is large. You can use the PDF table of contents to narrow down to the topics you need, such as I/O ports or A/D converter.
What should I know when I want to learn interrupt? PS0 PS1 PS2 PSA and bla bla.... I need to understand that kind of things ryte ? about the crystal oscillator, period and overflow?
Thank you