;================================================= ; ;================================================= ; ; zsMCU51 ; ; ; ; QQ:105558851 ; ; http://www.zsmcu.com ; E-mail:info@zsmcu.com ;================================================= ORG 0000H LJMP START; ORG 0010H START: MAIN: JNB P2.2,IR LJMP MAIN ;P3.2ж IR: MOV R6,#9 SB: ACALL DELAY882 ;882 JB P2.2,EXIT ;882жP2.2о DJNZ R6, SB ;10Σ8820 ;9000 JNB P2.2, $ ;9 ACALL DELAY2400 JNB P2.2,IR_Rp ; ACALL DELAY2400 ;4.744.5 MOV R1,#1AH ;趨1AHRAM MOV R2,#4 PP: MOV R3,#8 JJJJ: JNB P2.2,$ ;λ LCALL DELAY882 ;882ж MOV C,P2.2 ;P3.201C JNC UUU ;0UUU LCALL DELAY1000 UUU: MOV A,@R1 ;R1еA RRC A ;Cе01Aеλ MOV @R1,A ;AеR1 DJNZ R3,JJJJ ;8λ INC R1 ;R1е1RAM DJNZ R2,PP ;16λ8λ8λ1AH/1BH/1CH/1DHRAM MOV P1,1DH ;P18LED! CLR P2.3 ; LCALL DELAY2400 LCALL DELAY2400 LCALL DELAY2400 SETB P2.3; LJMP MAIN IR_Rp: LJMP MAIN EXIT: LJMP MAIN ; ;=============================882 DELAY882: ;1.085x ((202x4)+5)=882 MOV R7,#202 DELAY882_A: NOP NOP DJNZ R7,DELAY882_A RET ;=============================1000 DELAY1000: ;1.085x ((229x4)+5)=999.285 MOV R7,#229 DELAY1000_A: NOP NOP DJNZ R7,DELAY1000_A RET ;=============================2400 DELAY2400: ;1.085x ((245x9)+5)=2397.85 MOV R7,#245 DELAY2400_A: NOP NOP NOP NOP NOP NOP NOP DJNZ R7,DELAY2400_A RET END ;================================================= ; ;================================================= ; ; PIC ; ЩЩ51 滻 INCLUDE ; PICC д C ; QQ:316362373 ; MSNycskkk@MSN.COM ; http://CS168.YS168.COM ; E-mail:bigtree@56.com ; ;------------------------------------------------------------------------------ ;0 ;ü M,N ;IrDataA,IrDataB,IrDataC,IrDataD 8λ_ 8λ_8λ_8λ 32λ ;------------------------------------------------------------------------------- ; ;// IR.asm 2006-03-23 ;// PIC16F876APIC16F877A1.8432MWDT=OFFXT MODE ; ; ERRORLEVEL -205 ;Found directive in column 1. (ENDM) ; ERRORLEVEL -302 ;Register in operand not in bank 0. INCLUDE INCLUDE ;MACRO.INC ;SET_OPTION MACRO VAL ;SET_TRIS MACRO PORT,VAL ;MOVLF MACRO FX,VAL ;MOVFF MACRO FX2,FX1 ;FX1-->FX2 ;COMPARE MACRO FX10,FX11,LARGER,EQUAL,SMALLER ;FX10-FX11С ;JNB MACRO FX,BIT,TABLE ;λ0 TABLE ;JB MACRO FX,BIT,TABLE ;λ1 TABLE ;CPL MACRO FX,BIT ;λ ;----------------------------------------------------------------------- W_TEMP EQU 7FH ;W01 ;W_TEMP EQU 0FFH ;(16F873/874豣FFH) PCLATH_TEMP EQU 7EH ;PCLATH STATUS_TEMP EQU 7DH ;STATUS OPTION_TEMP EQU 7CH ; VALUE EQU 7BH ;дEEPROM ADDR EQU 7AH ;дEEPROM PORTB_TEMP EQU 79H ;PORTB M_TEMP EQU 78H N_TEMP EQU 77H ;R0 EQU FSR ;@R0 EQU INDF R1 EQU FSR R0 EQU INDF RMT EQU RA1 BUZ EQU RC6 CLK EQU RB3 DAT EQU RB2 NUM_D EQU 20H ;λ 4λ NUM_B EQU 21H ;λ 8λ DIR_TEMP EQU 23H ; M EQU 24H ;250us,10ms,100MS N EQU 25H KEY_FLAG EQU 26H ;мж B5H ò FLAGS EQU 27H IrDataA EQU 28H IrDataB EQU 29H IrDataC EQU 2AH ;30H 292A IrDataD EQU 2BH ;31H A EQU 32H ;COMFB R2 EQU 33H R3 EQU 34H R4 EQU 35H R5 EQU 36H R6 EQU 37H R7 EQU 38H A_DATA EQU 39H ;A_DATA IRA EQU 3BH IRB EQU 3CH IRC EQU 3DH IRD EQU 3EH ;-------------ICD2--------------------------------------------------------------------- ;70H7FH ж ;20H6FH ;A0HEFH \ ;110H16FH -- STATUS IRP RP1 RP0 ;190H1EAH / ;0x1EB 0x1EC 0x1ED 0x1EE 0x1EF ICD ;MPLAB-ICDPIC16F876/877洢洢 ;0x70, 0xF0,0x170,0x1F0 0x70 0x18E 0x18F() 0x1EB 0x1EC 0x1ED 0x1EE 0x1EF 洢 ;0x1F00-0x1FFF 256洢 ;BCF INTCON,GIE ;INTCON ;BSF INTCON,XX ;жλ ;BSF INTCON,GIE ; GIE-0GIE-1 ; SLEEP ;ж λ1 ; NOP ;NOP ;------------ λ ж------------------------------------------------------------------ ORG 0000H ; NOP ;ICD CLRF PCLATH GOTO START ; ORG 0004H GOTO SERV MAIN BTFSS PORTA,RMT ; GOTO RCV ; GOTO MAIN RCV BTFSC PORTA,RMT GOTO MAIN IR MOVLF R6,.10 SB CALL DELAY882 ;882 BTFSC PORTA,RMT ;882жP3.2о GOTO MAIN ;ж DECFSZ R6,F ;10Σ8820 GOTO SB NOP NOP ; MOVLF IrDataC,8 ; MOVLF IrDataD,18H SJ ;9000 JNB RA,RMT,SJ ;9 LCALL DELAY2400 JNB RA,RMT,IR_Rp LCALL DELAY2400 ;4.744.5 MOVLF FSR,IrDataA ;趨1AHRAM MOVLF R2,.4 PP ; MOVLF R3,.32 MOVLF R3,.8 JJJJ JNB RA,RMT,JJJJ ;λ LCALL DELAY882 ;882ж BTFSS RA,RMT ;MOV C,P2.2 ;RA101C CLRC BTFSC RA,RMT SETC JNC UUU ;0UUU CALL DELAY250uS ;LCALL DELAY1000 CALL DELAY250uS ;8M 8 CALL DELAY250uS ;4M CALL DELAY250uS ;CALL DELAY250uS ;CALL DELAY250uS ;CALL DELAY250uS ;CALL DELAY250uS UUU ; RRF IrDataD ; RRF IrDataC ; RRF IrDataB ; RRF IrDataA MOVFF A,INDF ;R1еA * AW RRF A ;Cе01Aеλ MOVFF INDF,A ;AеR1 DJNZ R3,JJJJ ;8λ INCF FSR,F ;R1е1RAM DJNZ R2,PP ;16λ8λ8λ1AH/1BH/1CH/1DHRA NOP NOP NOP SETB RC,BUZ CALL DELAY2400 CALL DELAY2400 CALL DELAY2400 CALL DELAY2400 CLRB RC,BUZ LJMP MAIN IR_Rp LJMP MAIN EXIT LJMP MAIN ; ;*********************滻******************************** ; MACRO.INC ;SET_OPTION MACRO VAL ;SET_TRIS MACRO PORT,VAL ;MOVLF MACRO FX,VAL ;MOVFF MACRO FX2,FX1 ;FX1-->FX2 ;COMPARE MACRO FX10,FX11,LARGER,EQUAL,SMALLER ;FX10-FX11С ;W00HZ1 MACRO TABLE ;JUMP_0 MACRO FX,BIT,TABLE ;λ0 TABLE ;JUMP_1 MACRO FX,BIT,TABLE ;λ1 TABLE ;JNB MACRO FX,BIT,TABLE ;λ0 TABLE ;JB MACRO FX,BIT,TABLE ;λ1 TABLE ;COMFB MACRO FX,BIT ;λ ;CPL MACRO FX,BIT ;λ ; ;OPTION SET_OPTION MACRO VAL BANKSEL OPTION_REG MOVLW VAL ; MOVWF OPTION_REG CLRF STATUS ;BANK0 ENDM ;趨I/O SET_TRIS MACRO PORT,VAL BANKSEL PORT|0X80 MOVLW VAL MOVWF PORT|0X80 CLRF STATUS ENDM ; MOVLF MACRO FX,VAL MOVLW VAL MOVWF FX ENDM ; MOVFF MACRO FX2,FX1 ;FX1-->FX2 MOVFW FX1 MOVWF FX2 ENDM COMPARE MACRO FX10,FX11,LARGER,EQUAL,SMALLER MOVF FX11,W ;FX11W SUBWF FX10,W ;FX10-WW BTFSC 3,Z ;Z=0, GOTO EQUAL ;FX10=FX11EQUAL BTFSC 3,C ;C=0, GOTO LARGER ;FX10FX11,LARGER GOTO SMALLER ;FX10F11 ENDM ;W=00HZ=1 TABLE W00HZ1 MACRO TABLE BTFSC STATUS,Z ;Z=1 W = 00H GOTO TABLE ENDM JUMP_0 MACRO FX,BIT,TABLE ;λ0 TABLE BTFSS FX,BIT GOTO TABLE ENDM JUMP_1 MACRO FX,BIT,TABLE ;λ1 TABLE BTFSC FX,BIT GOTO TABLE ENDM JNB MACRO FX,BIT,TABLE ;λ0 TABLE BTFSS FX,BIT GOTO TABLE ENDM JB MACRO FX,BIT,TABLE ;λ1 TABLE BTFSC FX,BIT GOTO TABLE ENDM JNC MACRO TABLE BTFSS STATUS,C GOTO TABLE ENDM JC MACRO TABLE BTFSC STATUS,C GOTO TABLE ENDM ;λ COMFB MACRO FX,BIT MOVLF R6,BIT INCF R6 SETC CLRF R7 RLF R7 DECFSZ R6 GOTO $-2 MOVFW R7 XORWF FX ENDM ;λ CPL MACRO FX,BIT MOVLF R6,BIT INCF R6 SETC CLRF R7 RLF R7 DECFSZ R6 GOTO $-2 MOVFW R7 XORWF FX ENDM SETB MACRO FX,BIT BSF FX,BIT ENDM CLRB MACRO FX,BIT BCF FX,BIT ENDM JMP MACRO TABLE GOTO TABLE ENDM AJMP MACRO TABLE GOTO TABLE ENDM LJMP MACRO TABLE GOTO TABLE ENDM ACALL MACRO TABLE CALL TABLE ENDM ;10TABLE DJNZ MACRO FX,TABLE DECFSZ FX,1 GOTO TABLE ENDM RRC MACRO FX ;A EQU XX ж RRF FX,1 ENDM INC MACRO FX INCF FX ENDM RTCC EQU H'0001' RA EQU H'0005' RB EQU H'0006' RC EQU H'0007' ;----- PORTA -------------------------------------------------------- RA7 EQU H'0007' RA6 EQU H'0006' RA5 EQU H'0005' RA4 EQU H'0004' RA3 EQU H'0003' RA2 EQU H'0002' RA1 EQU H'0001' RA0 EQU H'0000' ;----- PORTB -------------------------------------------------------- RB7 EQU H'0007' RB6 EQU H'0006' RB5 EQU H'0005' RB4 EQU H'0004' RB3 EQU H'0003' RB2 EQU H'0002' RB1 EQU H'0001' RB0 EQU H'0000' ;----- PORTC -------------------------------------------------------- RC7 EQU H'0007' RC6 EQU H'0006' RC5 EQU H'0005' RC4 EQU H'0004' RC3 EQU H'0003' RC2 EQU H'0002' RC1 EQU H'0001' RC0 EQU H'0000'