The PCB schematic is as follows. I remember it was drawn with protel at that time.
The circuit schematic is as follows: Drawing software is the same as above
Experiment reference C language code
#include "stc12c2052ad.h"
#include "wifi_IR.h"
#include //#define ENABLE_IAP 0x83 //if SYSCLK<20MHz #define FOSC 11059200UL //12M crystal #define CMD_IDLE 0 //Stand-By #define CMD_READ 1 //Byte-Read #define CMD_PROGRAM 2 //Byte-Program #define CMD_ERASE 3 //Sector-Erase uint addr; //EPPROM address //uchar cou; bit study_send_switch,LED_state; void SaveLevelTimeLength(uint addr); //Store level time void IrSend(); //infrared transmission void Read_Key(); void IrStudy(); void IapIdle(); void byte_write(uint addr, uchar dat); void SectorErase(uint sector_addr); uchar byte_read(uint addr); void TIMER0_RELOAD(uint addr) //load timer { TR0=0; TF0=0; TH0=byte_read(addr); //Read the length of the level from the specified address TL0=byte_read(addr+1); //Read the length of the level from the specified address TR0=1; //Start the timer } //--------------------------------------------------- void IrSend() // infrared transmission { uchar level_cnt; //Number of levels level_cnt=byte_read(addr); //Read the number of levels addr++; //move the address back one position while (1) { F38_4KHZ_ON(); //Because most of the infrared codes start with a high level, this is turned on from the beginning. TIMER0_RELOAD(addr); //Load the duration into the timer and start timing addr+=2; // The address is moved to a place that has not been taken before. The TIMER0_RELOAD function takes the data of two addresses while (!TF0); //Wait for timer 0 to overflow if(level_cnt–==0)break;//Judge whether the acquisition is completed F38_4KHZ_OFF(); IR_SEND = 1; //stop transmitting TIMER0_RELOAD(addr); //Load the duration into the timer and start timing addr+=2; //The address is moved to a place that has not been taken before. The TIMER0_RELOAD function takes the data of two addresses while (!TF0); //Wait for timer 0 to overflow if(level_cnt–==0)break;//Is the level completed? } F38_4KHZ_OFF(); IR_SEND = 1; //stop transmitting } //--------------------------------------------------- void SaveLevelTimeLength(uint addr) //Save level time { TR0=0; byte_write(addr, ~TH0); byte_write(addr+1, ~TL0); //Store the level duration in eeprom TH0=0; //The timer initial value is reset to 0 TL0=0x65; //According to the manual, it takes 55us to program one byte, and 110us to program two bytes. TR0=1; //Start counting } void IrStudy() { uint level_cnt; uint addrtmp; TF0 = 0; SectorErase(addr); addrtmp=addr; //Record the first address and store the number of levels addr++; TR0=0; //stop counting while (IR_REV); //Wait for the infrared receiving pin to be low //Encoding and decoding are a pair of inverse processes. Not only in principle, they are also inverse processes in the code sending and receiving process. That is, the original signal at the transmitting end is a high level, and the output of the receiving head is a low level. TH0=0; TL0=0; TR0=1; //Start the timer while (1) { while (!IR_REV) //Wait for high level, wait for timeout; exit after 70MS { if (TF0) { goto StudyFinish; } } SaveLevelTimeLength(addr); //When high level arrives, save low level duration to eeprom} level_cnt++; addr += 2; while (IR_REV) //Wait for low level, wait for timeout; exit after 70MS { if (TF0) { goto StudyFinish; } } SaveLevelTimeLength(addr); // Save the high level time when the low level arrives level_cnt++; //The number of stored levels plus 11 addr+=2; //Address moves two digits backward } StudyFinish: TF0=0; TR0=0; byte_write(addrtmp,level_cnt); level_cnt = 0; } void Delay100ms() //@11.0592MHz { unsigned char i, j, k; nop(); nop(); i = 5; j = 52; k = 195; do { do { while (–k); } while (–j); } while (–i); } void IapIdle() { IAP_CONTR = 0; //Close IAP function IAP_CMD = 0; //Clear command to standby IAP_TRIG = 0; //Clear trigger register IAP_ADDRH = 0x80; //Data ptr point to non-EEPROM area IAP_ADDRL = 0; //Clear IAP address to prevent misuse } /************************************************************************ Function name: Byte Write Global variables: None Parameter description: addr: write address, dat: write data ****************************************************************************/ void byte_write(uint addr,uchar dat) { IAP_CONTR = ENABLE_IAP; //Open IAP function, and set wait time IAP_CMD = CMD_PROGRAM; //Set ISP/IAP/EEPROM PROGRAM command IAP_ADDRL = addr; //Set ISP/IAP/EEPROM address low IAP_ADDRH = addr >> 8; //Set ISP/IAP/EEPROM address high IAP_DATA = dat; //Write ISP/IAP/EEPROM data IAP_TRIG = 0x46; //Send trigger command1 (0x46) IAP_TRIG = 0xb9; //Send trigger command2 (0xb9) nop(); nop(); nop(); nop(); IapIdle(); }
Previous article:Application of MCU 74LS138
Next article:Graduation Project of Temperature Controller Using PID Algorithm for 51 Single Chip Microcomputer
- 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
- 3 Benefits of Using Low IQ Buck/Boost Converters to Extend Flow Meter Battery Life
- Introduction to Power Factor Correction Technology in AC/DC Front-End Converter Modules
- Raspberry Pi Foundation Launches $4 Raspberry Pi Pico with MicroPython Support
- EEWORLD University ---- Overcurrent Sensing Technology
- [Zero-knowledge ESP8266 tutorial] Quick Start 23 Applying OLED
- SIMterix-Simplies~3~ Verilog-A
- C2000 Power-on Boot Mode Analysis
- CAN bus research notes
- DSP timer and interrupt system realizes variable frequency flashing of LED lights
- STM32F103VE DAC+DMA+TIM, channel 1, no signal output