Hi

I notice that you have a 20Mhz external crystal with caps, I believe that you should be setting OSC to HS and not XT.


did you say you have 16F877 maybe also check your new chip is the same and not an 16F877A


Hope this may help