Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
You are asking for "RMW" troubles with code like sequential writes to a PORTx register.
That MCU has LAT registers so you should always obey the golden rule: "Read form the PORT, write to the LAT".
Also NEVER play wth the GIE bit in an ISR. Read the last few paragraphs of Section 9.0 of the data sheet to understand why your code is ineffective (or at least the tiny snippet that you have shown).
Why are you defining TRISA to be 0 - that makes no sense at all. Also unless you set the REAL TRISA bits for output, they will default to input.
The PIC18F4550 does not have any ADSELx registers. I have no idea how the compiler managed to not throw all sorts of errors (unless you have more statements like the TRISA define that defines a variable called ANSELA).
What are you trying to do with the assignments to PORTAbits.AN0! I would doubt if there is a bit defined with that name (but I could be wrong there) as the data sheet shows that the *function* AN0 is an analog input using that pin. Therefore there is no point in assigning a value to it.
Can I suggest that you start with a 'flash a LED' style program so that you understand the basics. Also read the data sheet and don't copy code that you don't understand. That is not the way to learn.
* no free pins at all
* internal pullup / pulldiwn
* programmable pullup / pulldown
* external pullup / pulldown
* external hard wiring
Each has it's benefit and drawback. That's why they exist...
Asking for the best rarely gives a single good answer.