Infrared learning remote control based on stc89c52 microcontroller

Publisher:omicron25Latest update time:2023-07-19 Source: elecfansKeywords:stc89c52 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  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 ;


Keywords:stc89c52 Reference address:Infrared learning remote control based on stc89c52 microcontroller

Previous article:Design of STC8H8K64U microcontroller compatible with STC89C52 development board
Next article:About STC89C52 series microcontroller circuit arrangement

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号