Encoding and decoding of infrared remote control based on msp430 (with source code)[Copy link]
//Encoding and decoding waveform (NEC) //________________ __ __ __ // | | | | | | // | | | | | | | | // | | | | | | | | | // | | | | | | |..................................... // | | | | | | | | // | | | | | | | | // |________| |_| |__| "0" high: 0.56ms+low: 0.565ms=1.125ms //|<- 9ms ->|<-4.5ms>|"0"| "1"| "1" high: 0.56ms+low: 1.69ms =2.25ms //|<- boot code->|<-start code|<-8-bit address->|<-8-bit address->|8-bit data->|<-data inverse code->| //Resources occupied: TB CCR0 interrupt CCR4 CCR5 interrupt CCR0 is assigned 1125 clock 1MHz //Infrared output terminal P2.0 32768Hz //P2.1 is the infrared input port. This code is a common infrared remote control code, which can complete the transmission of infrared remote control or infrared data. The main algorithm is: Coding: Use 3278Hz frequency (P2.0 second function output ACLK) to drive the infrared diode to send data (should be 38KHz infrared receiving head requirements, I use close-range simulation, considering the precious timer resources, temporarily use 32K instead, it has been verified that close-range transmission can be completed, and it can be used by TA's P1.2 output, just slightly change the program: initialize TA, let P1.2 port output 38K pwm wave, change BIT_0/1 in the macro definition to the second function switch of P1.2 port) When sending, the interrupt control time of CCR0 of TB is used to complete the infrared transmission of 9ms and the stop of 4.5ms, and then the interrupts of CCR0 and CCR4 are used to complete the data transmission decoding: CCR5 is interrupted every 450ms to detect the data and enter the data frame if the low level is found. If the guide code and start code are correct, it enters the data receiving logic to complete the data segment reception
完整源代码:红外编解码.rar(3.01 KB, downloads: 72)