Using a oscillator frequency of 8MHz makes it very difficult to generate 50Hz PWM using the CCP modules.
I would suggest using a timer interrupt.
Step 1: You first set the timer for the ON duration of duty cycle, between 0.9ms to 2.1ms as previously mentioned, then set the pulse high.
Step 2: When the timer expires in the ISR, you bring the pulse low and reset the timer for the remain period of the cycle (< 20ms).
Step 3: When the timer expires you are back to Step 1.
Following these steps you will generate a PWM of 50Hz and by varying the ON duration or duty cycle you will be able to control the position of the servo.
A duty cycle of 1.5ms and a remaining period of 18.5ms will in effect put the servo into idle position, half way between the minimum and maximum positions.
The tutorial I gave you the link explains these principles well.
Does this info help?
BigDog
---------- Post added at 17:35 ---------- Previous post was at 17:16 ----------
now the problem is how i can move the servo , 0,90,137,180,270,360 degree ?
now i have -90 and +90 ..
By the way most, but not all, RC Servos have a limited range of +/- 90°, which you have already reached.
What is the make and model of the Servo you are using? I'll attempt to look the specs.
To implement a set of preset position points, degrees of rotation, you could use an array with duty cycle values required to position the servo at various points of rotation.
Moving the servo to a preset position would simply required to retrieve the value of the duty cycle from the array, subtract it from 20ms, and now you have both values required to rotate the servo to the desired position.
Does this help?
BigDog