;***************************************
Reference address:Using 51 single chip microcomputer to simulate the remote control switch of air conditioner - assembly program
;Remote control 4 buttons analog 15F104E ;Internal oscillation 11.0592M ;Press 1 to make P3.0 low level, press 2 to make P3.1 low level, press 3 to make P3.2 low level, press 4 to make P3.3 low level; buzzer prompt, ;Self-learning function, press and hold the key to be learned for 2 seconds,;The buzzer will sound for a long time, and stop beeping when learning is successful ;*************************** YHM EQU 2fh; User code SET0 EQU 30H; SET1 EQU 31H; SET2 EQU 32H; SET3 EQU 33H; ;;;;;;;;;;;;;;;;;;;;;;;;; IAP_DATA EQU 0C2H IAP_ADDRH EQU 0C3H IAP_ADDRL EQU 0C4H IAP_CMD EQU 0C5H IAP_TRIG EQU 0C6H IAP_CONTR EQU 0C7H ENABLE_IAP EQU 83H ;When the system working clock is <12MHZ ;************************ IR_KEY BIT P3.5; infrared beep bit p3.3 MA1 EQU 7BH ; MA2 EQU 7CH ; MA3 EQU 7DH MA4 EQU 7EH ; RED_32 EQU 7FH; ;************ ORG 0H ;Program starts AJMP START ORG 30H ;************* ; MCU initialization START: mov p3,#0ffh MOV DPTR, #0 call EEPROMR mov 30h,a inc dptr call EEPROMR mov 31h,a inc dptr call EEPROMR mov 32h,a inc dptr call EEPROMR mov 33h,a MOV DPTR, #200h call EEPROMR mov 2fh,a ;******************************** MAIN: orl p3,#17h mov a,p3 anl a,#17h cjne a,#17h,d2 jmp d4 d2: call delay2S orl p3,#17h mov a,p3 anl a,#17h cjne a,#17h,d3 jmp d4 d3: cpl a anl a,#17h mov 20h,a clr beep d4: jb IR_KEY,MAIN ACALL IR mov a,20h jnz d4 AJMP MAIN ; return ;*************************** AND: PUSH ACC PUSH PSW LCALL DELAY1MS LCALL DELAY1MS LCALL DELAY1MS LCALL DELAY1MS JB IR_KEY,IR_OUT;;High level exit JNB IR_KEY,$; Wait for IR to become high level LCALL DELAY2MS380US LCALL DELAY2MS380US JB IR_KEY,IR_OUT; Is it low level? MOV R0,#MA1; The starting memory is 7CH, a total of 4 memories JJJ:MOV R3,#8 ;8 bits BBB:JNB IR_KEY,$;wait for IR to become high level ;Start counting after high level, count value 1 high level 1 MOV R2,#0 ;1MS count CCC: LCALL DELAY1MS JNB IR_KEY,DDD ;Low level jump out count INC R2;;High level continues counting CJNE R2,#3,CCC; prevent counting timeout AJMP IR_OUT DDD: CLR A CLR C SUBB A,R2 ; MOV A,@R0 RRC A MOV @R0,A ; process one bit DJNZ R3, BBB; 8-bit data INC R0; Change the next memory CJNE R0,#RED_32,JJJ ;Write 4 memory ; 4 8-bit codes are stored in MA1~MA4 ;------------------------------------- MOV A,MA4 CPL A CJNE A,MA3,IR_OUT jbc 0,s30 jbc 1,s31 jbc 2,s32 jbc 4,s33 MOV A,MA2; CJNE A,YHM,IR_OUT; CALL IR_GOTO IR_OUT: POP PSW POP ACC RIGHT s30:mov set0,MA3 call bao0 call bao1 setb beep jmp IR_OUT s31:mov set1,MA3 call bao0 call bao1 setb beep jmp IR_OUT s32:mov set2,MA3 call bao0 call bao1 setb beep jmp IR_OUT s33:mov set3,MA3 call bao0 call bao1 setb beep jmp IR_OUT ;---------------- IR_GOTO:mov a,ma3 [page] CJNE A,SET0,E11 clr beep clr p3.0 LCALL DELAY2MS380US LCALL DELAY2MS380US LCALL DELAY2MS380US setb p3.0 setb beep RIGHT E11: CJNE A,SET1,E12 clr beep clr p3.1 LCALL DELAY2MS380US LCALL DELAY2MS380US LCALL DELAY2MS380US setb p3.1 setb beep right E12: CJNE A,SET2,E13 clr beep clr p3.2 LCALL DELAY2MS380US LCALL DELAY2MS380US LCALL DELAY2MS380US setb p3.2 setb beep RIGHT E13: CJNE A,SET3,E14 clr beep clr p3.4 LCALL DELAY2MS380US LCALL DELAY2MS380US LCALL DELAY2MS380US setb p3.4 setb beep RIGHT E14:; RIGHT ;--------Delay------ DELAY2MS380US: ;1T 11.0592M MOV R6,#0DFH DL0: MOV R5,#1CH DJNZ R5,$ DJNZ R6,DL0 RIGHT DELAY1MS: ;1T 11.0592M MOV R6,#12H DL05: MOV R5, #98H DJNZ R5,$ DJNZ R6,DL05 NOP RIGHT DELAY255MS: ; MOV R7,#255 DL045: call DELAY1MS DJNZ R7,DL045 NOP RIGHT DELAY2S: ; MOV R4,#7 DL1s: call DELAY255MS DJNZ R4,DL1s RIGHT ;************************ ERASE:; Erase MOV IAP_CONTR,#83h; Allow IAP/IAP operation MOV IAP_CMD,#03H ; sector erase MOV IAP_ADDRH,DPH ; send high address MOV IAP_ADDRL,DPL ; send low address ACALL IAPXX ; trigger RIGHT ;************************ EEPROMW:; write MOV IAP_CONTR,#83h; Allow IAP/IAP operation MOV IAP_CMD,#02H ; Send write command MOV IAP_ADDRH,DPH ; send high address MOV IAP_ADDRL,DPL ; send low address MOV IAP_DATA,A; A is the data to be written ACALL IAPXX ; trigger RIGHT ;************************ EEPROMR:; read MOV IAP_CONTR,#83h; Allow IAP/IAP operation MOV IAP_CMD,#01H ; Send read command MOV IAP_ADDRH,DPH ; send high address MOV IAP_ADDRL,DPL ; send low address ACALL IAPXX ; trigger MOV A,IAP_DATA; put the read data into A RIGHT ;---------- IAPXX:; Trigger MOV IAP_TRIG, #5AH MOV IAP_TRIG, #0A5H ; NOP NOP right ;--------------------- IAP_Disable:; Disable IAP/IAP operation MOV IAP_CONTR,#0 MOV IAP_CMD,#0 MOV IAP_TRIG,#0 MOV IAP_ADDRH,#0FFH MOV IAP_ADDRL,#0FFH RIGHT bao0: MOV DPTR, #0;Save call ERASE mov a,30h call EEPROMW inc dptr mov a,31h call EEPROMW inc dptr mov a,32h call EEPROMW inc dptr mov a,33h call EEPROMW call IAP_Disable right bag1: MOV DPTR,#200h;Save call ERASE MOV A,MA2 mov 2fh,a call EEPROMW call IAP_Disable right END
Previous article:Design of an intelligent residential perimeter anti-theft alarm system based on RS485 bus
Next article:STC89C52RC 8-bit running light program
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- Beautiful Smart NeoPixel LED Cube
- Several issues about dual-port RAM memory
- How to choose an adjustable DC power supply?
- What electrical and electronic engineers must know
- Have you ever used a BP machine? It's 8012, but Japan has just said goodbye to BP machines
- Questions about ccsv8
- Exposing a black-hearted supplier
- About AD17 export step file SOLIDWORKS
- [ESP32-Audio-Kit Audio Development Board Review]——(1): Selecting a development environment based on vs code
- I don't understand the concept of divergence. Can anyone explain this concept in a vivid way and its relationship with inflow and outflow?