Hello with my pic running at 4 mhz this works. At 16 mhz it doesn't. It is due to the pulsin resolution but I can't work out what I need to change in order to get it working. Can someone explain it to my rather meagre brain?

Thanks

DEFINE PULSIN_MAX 1140 '>1140 RETURNS 0


IR VAR byte[4]
pulse VAR word
i VAR byte
stx VAR word 'start of transmission

init: IR[0]=0:IR[1]=0:IR[2]=0:IR[3]=0:i=0
PulsIn PORTA.4, 0, stx
If (stx<760) Then init

While PORTB.4=1:Wend 'wait space
Repeat
PulsIn PORTA.4, 1, pulse
If (pulse>100) Then
IR.0(i)=1 'set bit
EndIf
i=i+1

Until (i>31)
serout portA.5,6,[#IR[0],10,13,#IR[1],10,13,#IR[2],10,13,#IR[3],10,13]

GoTo init