Using IC capture to count when pulses happen

I have a device that needs to count when a line goes high and register that time. There are going to be 10 bits every 50-60 microseconds

I was figuring to use the IC1 capture on my rabbit 4120 to read the values.

The plan is to have PD6 be the starting line. When that goes high, the IC timer will read in the values on the PD5 input, latching the count when the signal goes high(or low depending on the product).

The simple algorithm was this:
Zero out IC counter
Wait until PD6 goes high

When PD5 goes high write counter to array value

When IC counter overflows stop reading PD5.

Display values to STDIO.

Wait until PD6 goes high.

I’m not sure I’m using the IC counter properly.

Here are some code snippets

    WrPortI(ICT1R, NULL, 0x28); //Stop the counter
	
WrPortI(ICCSR, NULL, 0x04); //Zero out counters

WrPortI(ICT1R, NULL, 0xA4);//start counter
capture_status = RdPortI(ICCSR); //read the status of the ICCSR
printf("capture status: %d 
", capture_status);
while((capture_status & 0x04) == 0)//loop until roll over 120usec later
			{
			capture_status = RdPortI(ICCSR); //read the status of the ICCSR
			if((capture_status & 0x10) == 1)
                        { //iff logic}
}//end of loop
//do code to display values captured from the iff block


Thanks for any help.