已阅读5页,还剩17页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
单片机软件解码(PT2240)说明如下:利用及:选用作为软件解码芯片:单片机时钟频率选用外部晶振:选用外部中断脚作为编码信号脚输入脚:可解芯片(脚的学习型编码芯片编码地址位:的次方重复几率万分之一):功能有:遥控器学习(上的作为学习按纽)清除记忆(长按上的即可清除遥控器地址的记忆):学习遥控器数量可以设定(可根据的大小随便设定):输出功能(有三路是单击遥控器双稳,可以通过上的可以看到结果还有一路是双击遥控器双稳):可选用的饿超再生超外差接收模块:过几天将公布的单片机软件解码资料/*/* 遥控器接收程序 */*/#include #include #define remote_geshu 10 /*/union BIT_16int TIMER1_REG;unsigned char REG2;union BIT_32unsigned long data_temp_long;unsigned char data_temp_byte4;/*/static union BIT_16 TIMER1_TEMP;/16位定时器1static union BIT_32 data_temp;/*/static volatile unsigned char rec_status 97;static unsigned char data_cout;/接收的遥控器码位数static unsigned char data;/接收的4位数据static unsigned int h_pulse;/高电平宽度static unsigned int l_pulse;/低电平宽度static unsigned char remote_cout;/遥控器数量static unsigned char remote_numb;/遥控器编号/*/static unsigned char TIMER15S1;/清除学习码按键长按时间static unsigned char TIMER15S2;/学习等待时间static unsigned char TIMER15S3;/遥控器数据缓冲时间static unsigned char TIMER15S4;/LED显示时间static unsigned char TIMER15S5;/static unsigned char TIMER15S6;/static unsigned char TIMER15S7;/static unsigned char TIMER15S8;/*/static bit head (unsigned)(&rec_status)*8+(0);/同步头标志位static bit learn (unsigned)(&rec_status)*8+(1);/学习标志位static bit recieved (unsigned)(&rec_status)*8+(2);/接收完成标志位static bit remote_button_status (unsigned)(&rec_status)*8+(3);/遥控器按键标志位static bit first_click_status (unsigned)(&rec_status)*8+(4);/遥控器按键单击标志位/*/* 数据接收 */*/unsigned char data_read(void)if(h_pulsel_pulse)if(l_pulse200)&(l_pulse1000)if(h_pulse(l_pulse200)&(h_pulse1000)if(l_pulse(h_pulse2)return 0;/数据为0return 2;/无效的数据/*/void clr_head(void)/清除寄存器data_cout=0;head=0; /*/#pragma interrupt_level 1void check_data(void)/检测数据是否正确if(head)switch(data_read()case 0:(data_temp.data_temp_long)=1;data_cout+;break;case 1:(data_temp.data_temp_long)23)INTE=0;recieved=1;clr_head();/*/#pragma interrupt_level 1void check_head(void)if(!head)&(!recieved)/if(h_pulse300)&(h_pulseh_pulse*27)&(l_pulse head=1;/*/#pragma interrupt_level 1void interrupt level_h_l(void)/* if(RAIF)/如果是电平中断PORTA=PORTA;RAIF=0;/TIMER1_TEMP.REG0=TMR1L;TIMER1_TEMP.REG1=TMR1H;TMR1H=0;TMR1L=0;if(RA4)/如果是低电平中断l_pulse=TIMER1_TEMP.TIMER1_REG;check_data();check_head();else/如果是高电平中断h_pulse=TIMER1_TEMP.TIMER1_REG;*/if(INTF)INTF=0;TIMER1_TEMP.REG0=TMR1L;TIMER1_TEMP.REG1=TMR1H;TMR1H=0;TMR1L=0;if(INTEDG)/低电平宽度INTEDG=0;l_pulse=TIMER1_TEMP.TIMER1_REG;check_data();check_head();elseINTEDG=1;h_pulse=TIMER1_TEMP.TIMER1_REG;if(T0IF)/T0IF=0;TIMER15S1+;TIMER15S2+;TIMER15S3+;TIMER15S4+;TIMER15S5+;TIMER15S6+;TIMER15S7+;TIMER15S8+;/*/* 遥控器学习 */*/void clr_learn_reg(void)unsigned char n;di();for(n=1;n=remote_cout*4;n+)eeprom_write(n,0);eeprom_write(70,0);eeprom_write(71,0);ei();/*/unsigned char compare_data(unsigned char eep_addr)unsigned char n;union BIT_32 addr_data; for(n=0;n20)remote_cout=0; /如果EEPROM是空的则为0/*/void check_learn_pro(void)unsigned char n;if(learn)learn=0;remote_numb=eeprom_read(70);/读出现在可以覆盖掉哪个遥控器的编号read_remote_cout();/读遥控器的数量if(remote_numb(remote_geshu-1)remote_numb=0;/如果遥控器的编号已经是最大的了 则从小开始if(remote_cout=0)|!compare_all_data()/如果还没有遥控器学习或没有相同地址的遥控器学习di();for(n=0;n30)/是否长按了3秒learn=0;/clr_learn_reg();RC4=0;elselearn=1;/TIMER15S2=0;TIMER15S4=0;RC4=1;elseTIMER15S1=0;if(TIMER15S260)learn=0;/if(TIMER15S32)/数据保持时间data=0;TIMER15S3=0;if(TIMER15S43)/LED显示时间RC4=0;if(recieved)TIMER15S3=0;recieved=0;TIMER15S4=0;RC4=1;check_learn_pro();check_out_pro(); INTE=1;/*/* 控制部分程序 */*/void control_init(void);/*/*声音部分程序*/*/*/unsigned char delay(unsigned int nus)for(;nus0;nus-)if(recieved=1) return 0;asm(nop);/*/unsigned char soud_one_fre(unsigned int cout,unsigned int delay_time)/发音程序if(recieved=1) return 0;INTE=0;for (;cout0;cout-)RC6=!RC6;delay(delay_time);RC6=0;INTE=1;/*/*急促的声音*/*/unsigned char soud_one_fre0(unsigned int time,unsigned int delay_time)for (;time0;time-)if(recieved=1) return 0;soud_one_fre(1000,10);delay(delay_time);/*/*救护的声音*/*/unsigned char soud_tow_fre0(unsigned int time)/for (;time0;time-)if(recieved=1) return 0;soud_one_fre(900,10);soud_one_fre(800,30);/*/*低-高音*/*/unsigned char soud_many_fre0(unsigned int time,unsigned int cout)for (;time0;time-)unsigned int delay_time;for(delay_time=50;delay_time10;delay_time-)if(recieved=1) return 0;soud_one_fre(cout,delay_time
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026重庆恒宜轩人力资源管理有限公司招聘笔试历年参考题库附带答案详解
- 2026辽宁大连中远海运川崎船舶工程有限公司招聘137人笔试历年参考题库附带答案详解
- 2026西南证券股份有限公司招聘30人笔试历年参考题库附带答案详解
- 2026福建漳州片仔癀上海家化口腔护理有限公司市场化用工人员招聘及笔试历年参考题库附带答案详解
- 2025贵州茅台酒厂集团招聘管理人员13人笔试历年参考题库附带答案详解
- 2025福建龙岩市上杭县殡仪馆有限公司招聘拟聘用人选笔试历年参考题库附带答案详解
- 2025-2030中国温室大棚行业发展趋势与投资战略研究研究报告
- 2026年国开电大房屋建筑混凝土结构设计形考考前冲刺测试卷附完整答案详解【历年真题】
- 2026中国短视频内容电商转化率与运营策略报告
- 2026年诊断学第九版押题模拟及答案详解【考点梳理】
- 2026年二级注册计量师(计量法律法规及综合知识)考试试题及答案
- 2026广东警官学院招聘事业单位人员5人备考题库及答案详解【夺冠】
- 房产巡检监督制度
- 2026年中考数学模拟试卷及答案解析(共四套)
- 2025年法医临床考试题库及答案
- 统编版(2026)八年级下册历史教材课后问题答案(全册)
- 北京理工大学《嵌入式系统》2024 - 2025 学年第一学期期末试卷
- 狂犬病预防控制技术指南2025版
- 沈阳汽车集团有限公司招聘笔试题库2026
- 浙江警察学院2025年三位一体综合评价面试真题(含答案)
- 纪检档案培训课件
评论
0/150
提交评论