hi guys

Accroding to the manual of the PBP at 20mhz the resolution of PULSIN is 2uS.
but i cant seems to make it work even at 40mhz . But when i used 12mhz xtal or below it work perfectly.

Is there something im mising here?

i really need to make it work at 20mhz or 40mhz.



here is my code:

Header Var Word ' Header pulse length
Packet Var Word ' 12-bit IR information
P_Val Var Byte ' The bit length 60us = 0, 120us = 1
IR_But Var Byte ' The BUTTON code returned
IR_Dev Var Byte ' The DEVICE code returned
Sony_LP Var Byte ' Temporary loop variable
Green_LED Var PortA.1 ' Assign the red LED to this pin

TRISA = 0
LOW Green_LED

START:

GOSUB IRIN
IF IR_But = 0 THEN HIGH Green_LED

GOTO START

IRIN:
IR_Dev=255:IR_But=255
Pulsin PortB.2,0,Header ' Measure the header length.

If Header < 1000 then Return ' Verify a good header
If Header > 1350 then Return ' If not valid then exit

For Sony_Lp=0 to 11 ' Do 12-bits

Pulsin PortA.2,0,P_Val ' Receive the IR bit pulse
If P_Val >= 450 then ' If it's >= 90 then we've received a 1
Packet.0[Sony_Lp]=1 ' So set the appropriate bit of PACKET
Else
Packet.0[Sony_Lp]=0
Endif
Next

' Split the 7-bit BUTTON code, and the 5-bit DEVICE code

IR_But=Packet & %01111111 ' Mask the 7 BUTTON bits

IR_Dev=(Packet >>7) & %00011111 ' Move down and mask, the 5 DEVICE bits
Return



sorry for my english.

best regards,
ferds