Will be hard to have the great answer since we don't see your code BUT
  • 1. is your SELECT CASE refer to i/o pins ? Be sure you use GPIO instead of PORTx
    2. about TRIS .... TRISIO instead of TRISx..
and such ... be sure you're using the right Register, Port name for the according PIC.