Hi, RCTech

Assuming DEFINE OSC doesn't interfere with osc speed for pulsin and pulsout, result won't be the same @ 4Mhz and @ 20 MHz. ratio will be 5 , as you tell.
The Valinpulse value will be the same for Pulsin and Pulsout.

Now, as RC is in your pseudo ... RC pulses values are ~ 80 to 220 @ 4Mhz and 400 to 1100 @ 20 Mhz ... okay, but...

@ 4Mhz, you write: Valinpulse var BYTE ....and @ 20 Mhz you MUST write : Valinpulse var WORD !!!

and I didn't see that in your code ...

Also take care, if you ever use DEFINE PULSIN_MAX to allow for the full signal ( 0 AND 1 state duration = full period )

Now, a little Trick seen nowhere :

Always Write : LOW PORTX.Y before a Pulsout statement ... many ununderstandable bugs come from here !!! ( explanation is in High capacitive loads behaviour of PICs ... and the Pulsout way of work )

Alain
30 years of R/C ...