Using 51 single chip microcomputer to simulate the remote control switch of air conditioner - assembly program

Publisher:飘然出尘Latest update time:2015-07-16 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
;***************************************
;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
Reference address:Using 51 single chip microcomputer to simulate the remote control switch of air conditioner - assembly program

Previous article:Design of an intelligent residential perimeter anti-theft alarm system based on RS485 bus
Next article:STC89C52RC 8-bit running light program

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号