/***************************************/ /* Target: avr microcontroller ATmega8l */ /* Crystal: 3.6864Mhz */ /* 2007.8.20 */ /* Source code of a learning air conditioner infrared remote controller written by a foreigner*/ /* AT24C512 stores the time data of 2 keys, */ /* Output through the serial port during learning and transmission*/ /* Both key learning and serial port learning are possible /*With multi-keyboard communication interface /***************************************/ //IRD-1V20 module address write EEPROM (2) #include#include #include #include #define SYSCLK 3686400UL #define uchar unsigned char #define uint unsigned int #define ulint unsigned long #define IRD_START TCCR2=0X19 #define IRD_STOP TCCR2=0X00 /* I2C device slave address 1 A0、A1、A2--GND == 0xa0 2 A0、A1、A2--VCC == 0xa6 */ /* 24c512 =65536 bytes,anykey include <1000 bytes */ #define devicecode 0x01 #define TWI_SLA_24C512 0xa0 //#define address 0x02 //Remote controller address //#define TWI_SLA_PCF8563 0xa2 #define MAX_ITER 200 #define TW_WRITE 0 #define TW_READ 1 // MT #define TW_REP_START 0x10 #define TW_START 0x08 #define TW_MT_ARB_LOST 0x38 #define TW_MT_SLA_ACK 0x18 #define TW_MT_SLA_NACK 0x20 #define TW_MT_DATA_ACK 0x28 #define TW_MT_DATA_NACK 0x30 // MR #define TW_MR_SLA_ACK 0x40 #define TW_MR_SLA_NACK 0x48 #define TW_MR_ARB_LOST 0x38 #define TW_MR_DATA_NACK 0x58 #define TW_MR_DATA_ACK 0x50 #define led_off PORTC|=(1< = MAX_ITER) return -1; begin: TWCR = (1< >8; /* high 8 bits of addr */ TWCR = (1< Since the code is too long and the length of this article is limited, the complete code of this version can be downloaded from http://www.51hei.com/ziliao/file/IRD-1V21.rar
This was obtained from a foreign forum. It has been tested and the crystal oscillator uses an external 3.6864Mhz. The internal rc crystal oscillator may not be stable.
Previous article:AVR MCU LED Experiment
Next article:Design and implementation of fatigue driving detection device based on ATMaga8
Recommended ReadingLatest update time:2024-11-16 19:51
- Popular Resources
- Popular amplifiers
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Metronom Real-Time Operating System RTOS for AVR microcontrollers
- Learn C language for AVR microcontrollers easily (with video tutorial) (Yan Yu, Li Jia, Qin Wenhai)
- ATmega16 MCU C language programming classic example (Chen Zhongping)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- 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
- Qinhengwei CH549 minimum system schematic PCB
- Wen's Oscillation Problem
- [Fudan Micro FM33LC046N Review] + SPI driven OLED
- Sensor popular data download collection
- Keil also released a community version
- Faint
- About STC8A8K64S4A12EEPROM allocation
- [Newbie Help] Regarding the circuit of single-chip microcomputer controlling bidirectional thyristor, I have a few questions to ask you
- MSP430F5529 generates PWM waves with CCS
- How to suppress IGBT collector overvoltage spike