合泰单片机HT66F018红外发射C程序及电路图_第1页
合泰单片机HT66F018红外发射C程序及电路图_第2页
合泰单片机HT66F018红外发射C程序及电路图_第3页
合泰单片机HT66F018红外发射C程序及电路图_第4页
合泰单片机HT66F018红外发射C程序及电路图_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、精选文档#include "HT66F018.h"#include "ExternRAM.h"void SendIRdata(char p_irdata) unsigned char iraddr1; /十六位地址的第一个字节 unsigned char iraddr2; /十六位地址的第二个字节 int i; char irdata,count; irdata=p_irdata; iraddr1=0x00; iraddr2=0xbf; /发送9ms的起始码 endcount=16;/223 _t1on=1; _t2on=1; dowhile(0<

2、endcount); /发送4.5ms的结果码 endcount=8;/117 _t1on=0; _pa7=1; dowhile(0<endcount); /发送十六位地址的前八位 irdata=iraddr1; for(i=0;i<8;i+) /先发送0.56ms的38KHZ红外波(即编码中0.56ms的低电平) endcount=1; _t1on=1; dowhile(0<endcount); /停止发送红外信号(即编码中的高电平) if(irdata-(irdata/2)*2) /判断二进制数个位为1还是0 endcount=3; /1为宽的高电平 else endco

3、unt=1; /0为窄的高电平 _t1on=0; _pa7=1; dowhile(count<endcount); irdata=irdata>>1; /发送十六位地址的后八位 irdata=iraddr2; for(i=0;i<8;i+) /先发送0.56ms的38KHZ红外波(即编码中0.56ms的低电平) endcount=1; _t1on=1; dowhile(0<endcount); /停止发送红外信号(即编码中的高电平) if(irdata-(irdata/2)*2) /判断二进制数个位为1还是0 endcount=3; /1为宽的高电平 else e

4、ndcount=1; /0为窄的高电平 _t1on=0; _pa7=1; dowhile(count<endcount); irdata=irdata>>1; /发送八位数据 irdata=p_irdata; for(i=0;i<8;i+) /先发送0.56ms的38KHZ红外波(即编码中0.56ms的低电平) endcount=1; _t1on=1; dowhile(0<endcount); /停止发送红外信号(即编码中的高电平) if(irdata-(irdata/2)*2) /判断二进制数个位为1还是0 endcount=3; /1为宽的高电平 else e

5、ndcount=1; /0为窄的高电平 _t1on=0; _pa7=1; dowhile(count<endcount); irdata=irdata>>1; /发送八位数据的反码 irdata=p_irdata; for(i=0;i<8;i+) /先发送0.56ms的38KHZ红外波(即编码中0.56ms的低电平) endcount=1; _t1on=1; dowhile(0<endcount); /停止发送红外信号(即编码中的高电平) if(irdata-(irdata/2)*2) /判断二进制数个位为1还是0 endcount=3; /1为宽的高电平 els

6、e endcount=1; /0为窄的高电平 _t1on=0; _pa7=1; dowhile(count<endcount); irdata=irdata>>1; endcount=16;/223 _t1on=1; dowhile(0<endcount); endcount=4;/223 _t1on=0; _pa7=1; dowhile(0<endcount); endcount=1;/223 _t1on=1; dowhile(0<endcount); _t1on=0; _pa7=1; _t2on=0; ZSD=1;#include "HT66F

7、018.h"void CHUSHIHUA()_wdtc = 0b10101000;/关闭看门狗for(_tbhp=0;_tbhp<=1;_tbhp+)/清RAM BANK0 和 RAM BANK1for(_tblp=0xA0;_tblp>0;_tblp+)_bp = _tbhp;/BP指向所清除的RAM Bank_mp1=_tblp;/MP1间接寻址指针_iar1=0;/IAR1间接数据_cpc = 0x08;/关闭比较器_acerl = 0x00;/关闭AD口,这样芯片的IO口才能作为IO使用_pbc0 = 1;/设置IO口为输出口/设置IO口初值为 _pbpu0 =

8、1;/设置IO口为输出口_pb0 =0;_pbc1 = 1;/设置IO口为输出口/设置IO口初值为 _pbpu1 = 1;/设置IO口为输出口_pb1 =0;_pbc2 = 1;/设置IO口为输出口/设置IO口初值为 _pbpu2 = 1;/设置IO口为输出口_pb2 =0;_pbc3 = 1;/设置IO口为输出口/设置IO口初值为 _pbpu3 = 1;/设置IO口为输出口_pb3 =0;_tm1c0 = 0b00010000;/f SYS默认为8M_tm1c1 = 0b10101000;/PWM 模式或单脉冲输出模式 _tm1rpl=0xcc; /CCRp 频率接近38K _tm1rph=0x00; /CCRp _tm1al=0x66; /CCRA 占空比为1/2 _tm1ah=0x00; /CCRA _t1cp=1; / _tm2c0 = 0b00000000;/f SYS1/4默认为8M/4_tm2c1 = 0b11000001;/PWM 模式或单脉

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论