Hi, Coyote

1) Did you try to use HIGH Portx.y ...

I noticed many times it is much more reliable than Portx.y = 1 in disturbed circuits ...

2) @ 20 Mhz, you also could try PULSIN instead of count ( as it is a square wave )... nominal result will be 20 ... and there will be a little less "rollover" issues ...

3) The ideal way would be to use the "capture" feature of the CCP modules ... in a '877 there are two modules !! ...

Darrel's instant interrupts are ... the easy way ... to make that. And it takes much, much, much less CPU time ...

Alain