Need Help With PIC18F4580+SK40C (Rookie)

i'm Only Know Basic using Of PIC18F4580
I'm Using UltraSonic Range Finder that have pin (Vcc:Trig:echo:GDN)
ardurio HC-SR04 Ultrasonic Sensor
///------------------- Programming -------------------------///
///----------------------------------------------------////
Above Program It seem Not working if someone can help with this??
Even i put PORTD = CCPR1L; and moniter with LED the LED not Even change when change in distance
I'm Using UltraSonic Range Finder that have pin (Vcc:Trig:echo:GDN)
ardurio HC-SR04 Ultrasonic Sensor
///------------------- Programming -------------------------///
- CODE: SELECT_ALL_CODE
#include <p18f4580.h>
#include <delays.h>
#pragma config OSC = HS
#pragma config LVP = OFF
#pragma config WDT = OFF
#pragma config DEBUG = OFF
#pragma config PBADEN = OFF
void detection(void);
void chk_isr(void);
unsigned char outOfRange;
unsigned int distance;
unsigned int data;
#pragma code My_HiPrio_Int=0x0008
void My_HiPrio_Int(void)
{
_asm
GOTO chk_isr
_endasm
}
#pragma interrupt chk_isr
void chk_isr(void)
{
if(PIR1bits.TMR1IF == 1) // timer1 overflow ?
{
PORTDbits.RD5 = 1;
outOfRange = 1 ; // set out of range flag
PIR1bits.TMR1IF = 0 ; // clear interrupt flag
T1CONbits.TMR1ON = 0;
}
}
void main(void)
{
CCP1CON = 0x05;
T3CON = 0x00;
T1CON = 0x00;
TRISD = 0x00;
TRISCbits.TRISC2 = 1;
TRISCbits.TRISC1 = 0;
TRISBbits.TRISB0 = 0;
CCPR1L = 0x00;
CCPR1H = 0x00;
INTCONbits.GIE = 1;
INTCONbits.PEIE = 1;
PIE1bits.CCP1IE = 1;
PIE1bits.TMR1IE = 1;
PIR1bits.TMR1IF = 0;
while(1)
{
TMR1L = 0;
TMR1H = 0;
outOfRange = 0;
CCP1CONbits.CCP1M0 = 1;
PIR1bits.CCP1IF = 0;
PORTBbits.RB1 = 1;
Delay10TCYx(10);
PORTBbits.RB1 = 0;
while(PIR1bits.CCP1IF == 0);
T1CONbits.TMR1ON = 1;
CCP1CONbits.CCP1M0 = 0;
PIR1bits.CCP1IF = 0;
while(PIR1bits.CCP1IF == 0)
{
if(outOfRange = 1)break;
}
T1CONbits.TMR1ON = 0;
data = CCPR1H << 8;
data = data | CCPR1L;
distance = data/145/2;
detection();
Delay1KTCYx(1);
}
}
void detection()
{
if(distance>8 && distance<14)
{
PORTDbits.RD1 = 1;
PORTDbits.RD2 = 0;
PORTDbits.RD3 = 0;
PORTDbits.RD4 = 0;
}
else if(distance>18 && distance<24)
{
PORTDbits.RD1 = 0;
PORTDbits.RD2 = 1;
PORTDbits.RD3 = 0;
PORTDbits.RD4 = 0;
}
else if(distance>28 && distance<34)
{
PORTDbits.RD1 = 0;
PORTDbits.RD2 = 0;
PORTDbits.RD3 = 1;
PORTDbits.RD4 = 0;
}
else if(distance>38 && distance<44)
{
PORTDbits.RD1 = 0;
PORTDbits.RD2 = 0;
PORTDbits.RD3 = 0;
PORTDbits.RD4 = 1;
}
else
{
PORTDbits.RD5 = 1;
}
}
///----------------------------------------------------////
Above Program It seem Not working if someone can help with this??
Even i put PORTD = CCPR1L; and moniter with LED the LED not Even change when change in distance