;***************************************;遙控4按鍵模擬 15F104E ;內(nèi)部振蕩11.0592M;按1就P3.0低電平,按2就P3.1低電平 按3就P3.2低電平 按4就P3.3低電平 ;蜂嗚器提示, ;自學(xué)習(xí)功能,按住要學(xué)習(xí)的鍵2秒,;蜂嗚器長(zhǎng)響,學(xué)習(xí)成功停止響;***************************YHM EQU 2fh;用戶碼SET0 EQU 30H;SET1 EQU 31H;SET2 EQU 32H;SET3 EQU 33H;;;;;;;;;;;;;;;;;;;;;;;;;;IAP_DATA EQU 0C2HIAP_ADDRH EQU 0C3HIAP_ADDRL EQU 0C4HIAP_CMD EQU 0C5HIAP_TRIG EQU 0C6HIAP_CONTR EQU 0C7HENABLE_IAP EQU 83H ;系統(tǒng)工作時(shí)鐘<12MHZ時(shí);************************IR_KEY BIT P3.5;紅外beep bit p3.3MA1 EQU 7BH ;MA2 EQU 7CH ;MA3 EQU 7DH MA4 EQU 7EH ;RED_32 EQU 7FH;;************ORG 0H ;程序開(kāi)始AJMP STARTORG 30H;*************; 單片機(jī)初始化START:mov p3,#0ffh MOV DPTR, #0call EEPROMRmov 30h,ainc dptrcall EEPROMRmov 31h,ainc dptrcall EEPROMRmov 32h,ainc dptrcall EEPROMRmov 33h,aMOV DPTR, #200hcall EEPROMRmov 2fh,a;********************************MAIN:orl p3,#17hmov a,p3anl a,#17hcjne a,#17h,d2jmp d4d2:call delay2Sorl p3,#17hmov a,p3anl a,#17hcjne a,#17h,d3jmp d4d3:cpl aanl a,#17hmov 20h,aclr beepd4:jb IR_KEY,MAINACALL IRmov a,20hjnz d4AJMP MAIN ;返回;***************************IR:PUSH ACCPUSH PSWLCALL DELAY1MSLCALL DELAY1MSLCALL DELAY1MSLCALL DELAY1MSJB IR_KEY,IR_OUT;;高電平退出JNB IR_KEY,$;等 IR 變?yōu)楦唠娖絃CALL DELAY2MS380USLCALL DELAY2MS380USJB IR_KEY,IR_OUT;是否低電平MOV R0,#MA1;起始內(nèi)存為7CH,共4個(gè)內(nèi)存JJJ:MOV R3,#8 ;8位BBB:JNB IR_KEY,$;等 IR 變?yōu)楦唠娖?高電平后開(kāi)始計(jì)數(shù),計(jì)數(shù)值1 高電平1MOV R2,#0 ;1MS計(jì)數(shù)CCC:LCALL DELAY1MSJNB IR_KEY,DDD ;低電平跳出計(jì)數(shù)INC R2;;高電平繼續(xù)計(jì)數(shù)CJNE R2,#3,CCC;防止計(jì)數(shù)超時(shí)AJMP IR_OUTDDD:CLR ACLR CSUBB A,R2 ;MOV A,@R0RRC AMOV @R0,A ;處理完一位DJNZ R3,BBB;8位數(shù)據(jù)INC R0;換下一個(gè)內(nèi)存CJNE R0,#RED_32,JJJ ;寫(xiě)完個(gè)4內(nèi)存;4個(gè)8位碼存入MA1~MA4中;-------------------------------------MOV A,MA4CPL ACJNE A,MA3,IR_OUTjbc 0,s30jbc 1,s31jbc 2,s32jbc 4,s33MOV A,MA2;CJNE A,YHM,IR_OUT;CALL IR_GOTOIR_OUT:POP PSWPOP ACCRETs30:mov set0,MA3call bao0call bao1setb beepjmp IR_OUTs31:mov set1,MA3call bao0call bao1setb beepjmp IR_OUTs32:mov set2,MA3call bao0call bao1setb beepjmp IR_OUTs33:mov set3,MA3call bao0call bao1setb beepjmp IR_OUT;----------------IR_GOTO:mov a,ma3
評(píng)論