PWM is simple.
The timer 2 prescaler and the period register (register PR2) will set the period of the PWM signal, which in turn sets the frequency of the PWM signal. Writing a value to CCP1RL changes the duty cycle, which changes the average voltage output. CCPR1L contains the 8 MSBs of the duty cycle while bits 4 and 5 in CCP1CON are the two LSBs for a 10-bit resolution.
Changing the duty cycle by modifying the value written to CCPR1L changes the average voltage output. The lower the duty cycle of the PWM signal, the lower the average voltage output.
Quite honestly, to drive an H-bridge driven motor with PWM you need 4 PWM outputs. The 16F877A only has 2. The 16F887 has an enhanced PWM module with 4 PWM outputs for this exact purpose.