关于STC12C5410AD红外解码问题

[复制链接]
 楼主| Jackson_lv 发表于 2013-5-4 15:05 | 显示全部楼层 |阅读模式
      想把STC89C52的红外解码程序移植到STC12C5410AD上,用89C52是能够正常解码的,解码成功之后P1口会取反。但是移植到12C5410AD上就不行了。有想过是分频不同的原因,89C52是12分频的,12C54是6分频,即内部晶振大约为6MHZ,通过设置CMOD寄存器可以调节为12分频,结果还是不行。还尝试过在烧写程序那里选择时钟源为外部晶振,仍然不行。。。不知道是什么原因呢?红外解码的程序如下
  1. void Data_Receive()
  2. {

  3.       
  4.       unsigned int temp;
  5.       char i,j;
  6.           do{
  7.       restart:
  8.           while(Ir_Pin);
  9.       temp=Ir_Get_Low();
  10.       if(temp<c(7800) || temp>c(8800)) continue;//if(temp<c(8500) || temp>c(9500)) continue;//引导脉冲低电平9000
  11.       temp=Ir_Get_High();
  12.       if(temp<c(3600) || temp>c(4700)) continue;//if(temp<c(4000) || temp>c(5000)) continue;//引导脉冲高电平4500
  13.       for(i=0;i<4;i++) //4个字节
  14.       for(j=0;j<8;j++) //每个字节8位
  15.       {
  16.       temp=Ir_Get_Low();
  17.       if(temp<c(200) || temp>c(800)) goto restart;
  18.       temp=Ir_Get_High();
  19.       if(temp<c(200) || temp>c(2000)) goto restart;
  20.       Ir_Buf[i]>>=1;
  21.       if(temp>c(1120))
  22.           {
  23.                Ir_Buf[i]|=0x80;
  24.                P1 = ~P1;
  25.           }
  26.       }
  27.           //delay_50ms(5);
  28.           Show_Data();
  29.           beep=0;
  30.           delay_50ms(2);
  31.           beep=1;

  32.           /*if(Ir_Buf[3] == 0xff)
  33.           {
  34.              P1 = 0x00;
  35.              Ir_Buf[0] = Ir_Buf[1] = Ir_Buf[2] = Ir_Buf[3] = 0x00;
  36.                  delay_50ms(20);
  37.                  P1 = 0xff;
  38.           }
  39.           Show_Data();*/
  40.       }

  41.           while(1);
  42. }

您需要登录后才可以回帖 登录 | 注册

本版积分规则

16

主题

80

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部