Maybe it's in code you didn't post but I don't see where you configured the 16F877a oscillator for internal/external and speed. DEFINE OSC 20 tells PBP what frequency you want so the chip itself might be defaulting to the 4MHz internal oscillator. That could cause a communication issue.