From your schematic it appears you are using an IR receiver. Which one?
IR receivers usually are active low while the code I supplied for the NEC protocol was for RF where the receiver is active high. Also, my code was meant to work with the RF transmitter code that accompanied it which used slightly different timing than the NEC IR protocol.
The EDN article is wrong about details of the NEC IR protocol. It is explained in this NEC datasheet.You will need to modify my RF code in order to receive/decode IR codes.I have not tested the above code (I don't have time to build a circuit with an IR receiver.) and you will need to convert it for your PIC and the pins you are using.Code:'12F629 @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF DEFINE PULSIN_MAX 1140 '>1140 RETURNS 0 DEFINE DEBUG_REG GPIO DEFINE DEBUG_BIT 2 'GPIO.2 DEFINE DEBUG_MODE 1 'Inverted DEFINE DEBUG_BAUD 9600 DEFINE OSCCAL_1K 1 IR VAR byte[4] pulse VAR byte i VAR byte stx VAR word 'start of transmission CMCON = 7 'comparators off Debug "IR NEC PROTOCOL" init: IR[0]=0:IR[1]=0:IR[2]=0:IR[3]=0:i=0 PulsIn GPIO.1, 0, stx If (stx<760) Then init 'debug #stx While GPIO.1=1:Wend 'wait space Repeat PulsIn GPIO.1, 1, pulse If (pulse>100) Then IR.0(i)=1 'set bit EndIf i=i+1 Until (i>31) For i = 0 To 3 Debug IHEX2(IR[i] REV 8) Next GoTo init End
Note also that my code does not deal with the NEC shortcut repeat code.




Bookmarks