Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/07/06 01:38
Read: times


 
#117910 - Receiving IR remote control code
Hello:

After three whole days of debugging I finally give up trying and ask for help here. (I have read the "Bible" and the tutorial)

I am now writing a code for my AT89S52 to receive a DVD remote control's command. It has been done before, with a polling method: Keep checking the IRRC pin (a port pin connected to the IR receiver module)

Now I am rewriting the program using interrupt. P3.2 is named IRRC.

A port pin CK (P3.3) is connected to my PC's soundcard MIC-in. Any debug pulses output will be recorded by a sound editor in my PC.

These are the result:
the upper waveform is the debug output of the MCU, and the waveform below is the IR receiver module's output (also connected to P3.2)

Any time INT0 occurs MCU will send two pulses in a short interval:


What troubled me a lot is right after the instruction RETI, INT0 is triggered again:


The following code is in fact extracted from the original receive code. Some recognition of IR code is done instead of DELAYs in the original receive code. It is not suitable to post the entire code here with hundreds of lines, especially when I am asking for debug help. Anyway the result above did generated by the following code:



                IRRC    EQU     P3.2    ;Connected to IR receive module. (INT0)
                CK      EQU     P3.3    ;Connected to PC's MIC-in.

                ORG     0000H
                JMP     Init
                ORG     0003H
                JMP     INT0
                ORG     0050H
Init:           CLR     CK              ;pull down the debug pin
                SETB    IT0             ;Enable INT0
                SETB    EX0
                SETB    EA
ST:             JMP     ST              ;Wait for remote control signal.
;               ---------------------
INT0:           CLR     EX0

        CALL    CKBIT                   ;whenever calling the CKBIT a single pulse will be sent to MIC-in
        CALL    IRRCSYNC                ;IRRCSync is just a delay module placed at the end of the program.
        CALL    CKBIT
                MOV     R5,#185         ;these DELAYS replaced the IR command recognition part, to "isolate" the problem code
temp:           CALL    IRRCSYNC
                DJNZ    R5,temp
        CALL    CKBIT                   ;This three CKBIT will be shown as a single LARGE pulse in PC
        CALL    CKBIT
        CALL    CKBIT
        CALL    IRRCSYNC                 ;a short delay so that the problem (INT again) can be shown clearly

                SETB    EX0
                RETI
;               ---------------------
IRRCSync:       MOV     R6,#10           ;Delay
IRRCSync6:      MOV     R7,#30
IRRCSync7:      DJNZ    R7,IRRCSync7
                DJNZ    R6,IRRCSync6
                RET
;               ---------------------
CKBIT:          SETB    CK               ;Debug pulse output.
                CLR     CK
                RET
;               ---------------------
                END



Thanks!

Stanley

List of 11 messages in thread
TopicAuthorDate
Receiving IR remote control code            01/01/70 00:00      
   What I would do            01/01/70 00:00      
      not the protocol            01/01/70 00:00      
   Not clearing IE0            01/01/70 00:00      
      IE0            01/01/70 00:00      
         IE0 does not need EX0 enabled            01/01/70 00:00      
            band-aids            01/01/70 00:00      
               timer in capture mode            01/01/70 00:00      
                  "Long" pulses?            01/01/70 00:00      
                     never use before            01/01/70 00:00      
            how to prevent IE0 set            01/01/70 00:00      

Back to Subject List