DEFINE LOADER_USED 1
DEFINE OSC 4
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 12 ' 19200 Bauds
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 Portb.3 ' Assign the red LED to this pin
IR_bin var word
TRISA = 0
LOW Green_LED
START:
GOSUB IRIN
IF IR_But =255 THEN start
HSEROUT ["IR_But ",DEC IR_But,13,10]
HSEROUT ["IR_Dev ",DEC IR_Dev,13,10]
GOTO START
IRIN:
IR_Dev=255:IR_But=255
Pulsin PortB.0,0,Header ' Measure the header length.
If Header < 216 then Return ' Verify a good header
If Header > 264 then Return ' If not valid then exit
For Sony_Lp=0 to 11 ' Do 12-bits
Pulsin PortB.0,0,P_Val ' Detech 1 Check space pluse ,Receive the IR bit pulse
If P_Val > 100 then ' If it's >= 90 then we've received a 1
'Packet.0[Sony_Lp]=1 ' So set the appropriate bit of PACKET
Packet.0=1
Else
'Packet.0[Sony_Lp]=0
Packet.0=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
Work well for sony remote
And now we try to HITACHI remote ,Space(0) type (sony remote , Pulse(1) type)
Still not work ......What i worng
'*** IR decode fro Hitachi remote*********
DEFINE LOADER_USED 1
DEFINE OSC 4
'DEFINE OSC 20
'// For PIC16F62x & A versions
'CMCON = 7 '// Comparators Off
'VRCON = 0 '// Vref Off
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 12 ' 19200 Bauds
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 Portb.3 ' Assign the red LED to this pin
IR_bin var word
TRISA = 0
LOW Green_LED
START:
GOSUB IRIN
IF IR_But =255 THEN start
HSEROUT ["Bottom ",DEC IR_But,13,10]
HSEROUT ["Comand ",DEC IR_Dev,13,10]
GOTO START
IRIN:
IR_Dev=255:IR_But=255
Pulsin PortB.0,0,Header ' Measure the header length.
If Header < 704 then Return ' Verify a good header
If Header > 968 then Return ' If not valid then exit
PAUSEUS 240 'wait for header space
For Sony_Lp=0 to 31 ' Do 32-bits
Pulsin PortB.0,1,P_Val ' Detech 1 Check space pluse ,Receive the IR bit pulse
If P_Val > 150 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_But=Packet.highbyte
'IR_Dev=(Packet >>7) & %00011111 ' Move down and mask, the 5 DEVICE bits
IR_Dev=Packet.highbyte
Return
Hitachi pluse detail , 32 bit , space type
IR head = 8800(+) , 2200 (-)
1 = 550(+) , 1650 (-)
0 = 550(+) , 550 (-)
Still not work ......What i wrong..
Bookmarks