打印

关于STC12C5410AD红外解码问题

[复制链接]
1908|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
Jackson_lv|  楼主 | 2013-5-4 15:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
      想把STC89C52的红外解码程序移植到STC12C5410AD上,用89C52是能够正常解码的,解码成功之后P1口会取反。但是移植到12C5410AD上就不行了。有想过是分频不同的原因,89C52是12分频的,12C54是6分频,即内部晶振大约为6MHZ,通过设置CMOD寄存器可以调节为12分频,结果还是不行。还尝试过在烧写程序那里选择时钟源为外部晶振,仍然不行。。。不知道是什么原因呢?红外解码的程序如下
void Data_Receive()
{

      
      unsigned int temp;
      char i,j;
          do{
      restart:
          while(Ir_Pin);
      temp=Ir_Get_Low();
      if(temp<c(7800) || temp>c(8800)) continue;//if(temp<c(8500) || temp>c(9500)) continue;//引导脉冲低电平9000
      temp=Ir_Get_High();
      if(temp<c(3600) || temp>c(4700)) continue;//if(temp<c(4000) || temp>c(5000)) continue;//引导脉冲高电平4500
      for(i=0;i<4;i++) //4个字节
      for(j=0;j<8;j++) //每个字节8位
      {
      temp=Ir_Get_Low();
      if(temp<c(200) || temp>c(800)) goto restart;
      temp=Ir_Get_High();
      if(temp<c(200) || temp>c(2000)) goto restart;
      Ir_Buf[i]>>=1;
      if(temp>c(1120))
          {
               Ir_Buf[i]|=0x80;
               P1 = ~P1;
          }
      }
          //delay_50ms(5);
          Show_Data();
          beep=0;
          delay_50ms(2);
          beep=1;

          /*if(Ir_Buf[3] == 0xff)
          {
             P1 = 0x00;
             Ir_Buf[0] = Ir_Buf[1] = Ir_Buf[2] = Ir_Buf[3] = 0x00;
                 delay_50ms(20);
                 P1 = 0xff;
          }
          Show_Data();*/
      }

          while(1);
}

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

16

主题

80

帖子

0

粉丝