Try the following link, it might help you
Interfacing HC-SR04 Ultrasonic Sensor with PIC Microcontroller