以单片机作为核心控制器的电子产品日益广泛使用,它们的操作方式主要还是由外接的键盘来完成。若在此类产品中增加红外遥控功能,将使它们的操作更加人性化。用单片机进行软件解码最普遍的方法有查询法和外部中断法,在此详细介绍一种用AT89S52单片机定时器T2捕获功能实现接收解码的新方法,给出了解码的程序流程图和相应的子程序。实践证明,该解码方法占用单片机资源少,程序代码运行稳定可靠,效率高。该解码方法可为单片机产品开发者提供一个非常实用的参考,也可为学习者提供一个典型的应用范例。
Microcontroller which is taken as a core controller in electronic products is widely used. Its operation mode is still performed by external keyboard. If the infrared remote control function is added in the electronic products, their operation will he more humanized. The most common methods for software decoding with MCU are the inquiry method and external interrupting method. A new method of realizing the receiving decoding by the capture function of AT 89S52 MCU Timer2 is introduced in detail. The program flowchart of the decoding and its corresponding subroutine are given in this paper. The practice application proves that the decoding method occupies less resources of MCU, and is stable, reliable and efficient in the code operation. This decoding method can provide a very useful reference for MCU developers, and a typical application example for the learners.