On smart TVs and Internet set-top boxes (TV boxes), the common mainstream remote controls are nothing more than "infrared" and "Bluetooth" remote control methods. "Bluetooth" remote controls have received more and more attention from manufacturers and favored by consumers in recent years due to their characteristics such as "no alignment required", "can be controlled around corners", and "long control distance". However, despite this, there are still a large number of users who insist on The reason for using infrared remote control is that many Bluetooth remote controls at this stage have many defects and problems, which affect users' daily operations.
A very detailed infrared learning remote control, the assembly subroutine stored in 24c64, you only need to modify the IO call in your own design. It is my engineering verification that it can learn most of the infrared remote controls commonly used in the market.
The stc89c52 microcontroller is used. The following is the assembly code:
;**********************************
;---------------------AT24C64 CODE-------------------------
;==========================================================
ICSTART: ;I2C start
SETB SDA
NOP
NOP
NOP
NOP
SETB SCK
NOP
NOP
NOP
NOP
CLR SDA
NOP
NOP
NOP
NOP
CLR SCK
RIGHT
;==========================================================
ICSTOP: ;I2C end
CLR SDA
NOP
NOP
NOP
NOP
CLR SCK
NOP
NOP
NOP
NOP
SETB SCK
NOP
NOP
NOP
NOP
SETB SDA
RIGHT
;==========================================================
ICACK: ;I2C response
CLR SDA
NOP
NOP
NOP
NOP
SETB SCK
NOP
NOP
NOP
NOP
CLR SCK
RIGHT
;==========================================================
NOACK: ;I2C no response
SETB SDA
NOP
NOP
NOP
NOP
SETB SCK
NOP
NOP
NOP
NOP
CLR SCK
RIGHT
;==========================================================
ICREADBIT: ;I2C reads one bit
SETB SDA
NOP
NOP
NOP
NOP
SETB SCK
NOP
NOP
NOP
NOP
MOV C,SDA
CLR SCK
RIGHT
;----------------------------------------------------------
ICREADACK:
MOV R7,#200
SETB SDA
NOP
NOP
NOP
NOP
SETB SCK
NOP
NOP
NOP
NOP
READACKS:
JNB SDA,ACKEND
DJNZ R7,READACKS
SETB C
CLR SCK
RIGHT
ACKEND:
CLR C
CLR SCK
RIGHT
;==========================================================
ICREADBYTE: ;I2C reads a byte
MOV R7,#8
READLOOP:
LCALL ICREADBIT
RLC A
DJNZ R7,READLOOP
MOV R7,A
RIGHT
;==========================================================
ICWRITEBIT: ;I2C write one bit
MOV SDA,C
NOP
NOP
NOP
NOP
SETB SCK
NOP
NOP
NOP
NOP
CLR SCK
RIGHT
;==========================================================
ICWRITEBYTE: ;I2C writes a byte
MOV A,R7
MOV R7,#8
WRITELOOP:
RLC A
LCALL ICWRITEBIT
DJNZ R7,WRITELOOP
RIGHT
;==========================================================
PLAYED:
MOV A, R7; calculate I2C address
MOV B,#208 ;144
MUL AB
MOV R2,B
MOV R3,A
LCALL ICSTART ;I2C data read into the buffer
MOV R7, #0A0H; R2R3 I2C address
LCALL ICWRITEBYTE ;R0 buffer address
LCALL ICREADACK ;R1 data number
JNC RACKEND
RIGHT
;
RACKEND:
MOV A,R2
MOV R7,A
LCALL ICWRITEBYTE
LCALL ICREADACK
MOV A,R3
MOV R7,A
LCALL ICWRITEBYTE
LCALL ICREADACK
LCALL ICSTART
MOV R7,#0A1H
LCALL ICWRITEBYTE
LCALL ICREADACK
MOV R0,#LRDBUF
MOV R1,#208 ;144
READDATAS:
LCALL ICREADBYTE
LCALL ICACK
MOV @R0,A
INC R0
DJNZ R1,READDATAS
LCALL NOACK
LCALL ICSTOP
RIGHT
;==========================================================
WRITEAT: ;Buffer data is written to I2C
MOV A, R7; calculate I2C address
MOV B,#208 ;;144
MUL AB
MOV R2,B
MOV R3,A
MOV R5,#13 ;9 13*16=208
MOV R0,#LRDBUF
ICWRITENEXT:
LCALL ICSTART
MOV R7,#0A0H
LCALL ICWRITEBYTE
LCALL ICREADACK
JNC WAKE UP
;
;
WACKEND:
MOV A,R2
MOV R7,A
LCALL ICWRITEBYTE
LCALL ICREADACK
MOV A,R3
MOV R7,A
LCALL ICWRITEBYTE
LCALL ICREADACK
MOV R1,#16
WRITED DATA:
MOV A,@R0
INC R0
MOV R7,A
LCALL ICWRITEBYTE
LCALL ICREADACK
DJNZ R1,WRITEDATAS
LCALL ICSTOP
MOV R7,#250
DELAY_D:
MOV R6,#20
DJNZ R6,$
DJNZ R7,DELAY_D
MOV A,R3
ADD A,#16
MOV R3,A
MOV A,R2
ADDC A, #0
MOV R2,A
DJNZ R5,ICWRITENEXT
RIGHT
;*****************************************************************
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
LRDREAD:
;Infrared code reading
MOV R0, #LRDBUF; code buffer cleared
MOV R1,#208 ;144
CLR A
CLRLRDBUF:
MOV @R0,A
INC R0
DJNZ R1,CLRLRDBUF
MOV R0,#LRDBUF
SETB LRDR
LRDTEST:
SETB TR2
SETB ES; Infrared code start detection
JB RI, LLOOP; This is to detect when a key is pressed. . . . . .
CLR TR2
JNB LRDR,READSTART
JB HWXX, LRDTEST; infrared learning flag bit
LJMP LLLOOP
LLOOP: ;
CLR RI
MOV A,SBUF
MOV R0,#250
MOV R1,#250
LP4: JB RI,LP3
DJNZ R0,LP4
DJNZ R1,LP4
LJMP LRDTEST
LP3: CLR RI
CLR ES
MOV A,SBUF
MOV A,#00H
LP2:
CLR HONGWAI ;Infrared button flag
CLR P3.3
CLR HWXX
MOV SBUF,#37H
JNB TI,$
CLR TI
DEC SP
DEC SP
LJMP LOOP
LLLOOP: RET
;--------------------------------------
READSTART:
CLR EA
;SETB P0.6
MOV TH1,#0
MOV TL1,#12
SETB LRDR
;--------------------------------------
READLOOP_S:
SETB TR1
CLR TF1
TEST_LRDR:
MOV A,TH1
JB TF1,LRDOVER
JNB LRDR,TEST_LRDR
CLR TR1 ;
Previous article:Design of STC8H8K64U microcontroller compatible with STC89C52 development board
Next article:About STC89C52 series microcontroller circuit arrangement
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- 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
- Silicon carbide industry chain science video: substrate and epitaxy
- Share an open source software download URL
- "Practice Together in 2021" + Looking Forward
- Senior foreigner explains the misunderstandings of high-speed PCB design and testing (video-Chinese)
- After zigbee sends data to nb-iot, nb-iot sends data to the cloud, but the data displayed on the cloud is completely wrong. How to solve it?
- Notice: The new markdown editor is now online!!
- Design of password lock using AT89S52 single chip microcomputer
- 【Development and application based on NUCLEO-F746ZG motor】4. Share information
- encryption
- Motor control basics - timer basics and PWM output principles