//40KHz OSC
void InitPWM(void)
{
PR2 = 24; //Set TIMER2 frequency
CCPR1L = 0B00001100; //Set TIMER2 duty cycle
CCP1CON = 0B00101111; //Set x,y CCP1CON<5:4> any CCP1CON<3:0> = 11xx = PWM mode
TMR2 = 0; //Clear TMR2 first
T2CON = 0B01111000; //T2CON<0:1>Set prescaler ,T2CON<2>=0 stop Timer2
}