In smart TVs and network set-top boxes (TV boxes), the two most common remote control methods are infrared and Bluetooth. In recent years, Bluetooth remotes have gained increasing attention from both manufacturers and users due to their advantages such as "no need for alignment," "control through bends," and "longer control distance." However, despite these benefits, many users still prefer infrared remotes, mainly because current Bluetooth remotes come with various issues that can affect daily use.
One of the most detailed solutions is an infrared learning remote control, which stores its data in the 24C64 chip using assembly code. This design allows for easy modification by changing the IO calls, and it has been verified to work with most infrared remotes available on the market. The system is based on the STC89C52 microcontroller, making it a reliable and cost-effective solution for custom remote control applications.
The following is the assembly code for the I2C communication with the 24C64 chip:
;**********************************
;---------------------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
RET
ICSTOP: ;I2C stop
CLR SDA
NOP
NOP
NOP
NOP
CLR SCK
NOP
NOP
NOP
NOP
SETB SCK
NOP
NOP
NOP
NOP
SETB SDA
RET
ICACK: ;I2C acknowledge
CLR SDA
NOP
NOP
NOP
NOP
SETB SCK
NOP
NOP
NOP
NOP
CLR SCK
RET
NOACK: ;I2C no acknowledge
SETB SDA
NOP
NOP
NOP
NOP
SETB SCK
NOP
NOP
NOP
NOP
CLR SCK
RET
ICREADBIT: ;I2C read one bit
SETB SDA
NOP
NOP
NOP
NOP
SETB SCK
NOP
NOP
NOP
NOP
MOV C, SDA
CLR SCK
RET
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
RET
ACKEND:
CLR C
CLR SCK
RET
ICREADBYTE: ;I2C read a byte
MOV R7, #8
READLOOP:
LCALL ICREADBIT
RLC A
DJNZ R7, READLOOP
MOV R7, A
RET
ICWRITEBIT: ;I2C write one bit
MOV SDA, C
NOP
NOP
NOP
NOP
SETB SCK
NOP
NOP
NOP
NOP
CLR SCK
RET
ICWRITEBYTE: ;I2C write a byte
MOV A, R7
MOV R7, #8
WRITELOOP:
RLC A
LCALL ICWRITEBIT
DJNZ R7, WRITELOOP
RET
READAT:
MOV A, R7 ; Calculate the I2C address
MOV B, #208 ; 144
MUL AB
MOV R2, B
MOV R3, A
This system provides a robust and flexible way to interface with external memory, allowing for advanced remote control functionality. Whether you're developing a custom remote or modifying an existing one, this code serves as a solid foundation for integrating infrared learning capabilities into your project. It’s especially useful for those who want to support a wide range of remote controls without having to rely on Bluetooth technology.
Longhua Manxueling Trading Company , https://www.mxlvape.com