Bear in mind that the minimum PWM frequency you can achieve with an osc @ 20 MHz is 1221 Hz. (see page 74 of PBP manual)

In your code the PWM frequency is set to 50 Hz.

Al.