Instead of using HPWM, try this:
Code:
PWM PORTB.0,speed,1000
You won't need to declare/define T2CON, CCP1CON, PR2 and CCPR1L.

PS: I'm using MCS