Refer data sheet in which CCP module give details of PWM
Unfortunately, ditch08 could memorize the datasheet section on the CCP module and it would be of little value, other than to come to the realization that using the CCP module of the PIC16F877A to generate a 50Hz PWM signal, period of 20ms, is an inappropriate choice unless of course you choose to use a slower than normal system clock frequency which has additional drawbacks.
@ditch08
Normally most PWM signals appropriate to drive RC Servos are generated by the PIC16F series devices by utilizing a timer, timer interrupts and interrupt service routine (ISR).
Using timer, timer interrupts and ISR to generate an appropriate PWM signal is preferable to software delays, as in your post example, as it always the PIC to perform other tasks, such as monitoring the resistance/position of a pot when the PIC is not servicing the interrupt.
The following reference document provides several examples of generating such a PWM signal in code:
How to Interface a Microchip PIC MCU with a hobby R/C Servo
The code examples in the above document are for the mikroC Pro Compiler, however they can be readily ported to other compilers such as the HiTech Compiler.
**broken link removed**
There are several possible techniques to controlling the servo position with a pot.
Post any additional questions you may have and I will gladly assist you.
BigDog