Bruce has a good explanation here.
It's for 38khz, but you just change the numbers for higher freqs. ...
Using The PIC Microcontroller Hardware PWM Feature & Infrared Communications
http://www.rentron.com/Infrared_Communication.htm
And for easy PWM calculations ...<br>