⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.lst

📁 采用C语言编写
💻 LST
字号:
C51 COMPILER V8.08   MAIN                                                                  01/15/2008 19:44:27 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <AT89X51.h> 
   2          
   3          static bit OP;        //红外发射管的亮灭
   4          static unsigned int count;       //延时计数器
   5          static unsigned int endcount; //终止延时计数
   6          static unsigned char Flag;      //红外发送标志
   7          char iraddr1;  //十六位地址的第一个字节
   8          char iraddr2;  //十六位地址的第二个字节
   9          
  10          void SendIRdata(char p_irdata);
  11          void delay();
  12          char getkey()
  13          {
  14   1                P1=0xfe;P3_6=P3_7=1;P3_3=1;
  15   1                if(!P1_4)return 1;   //ON
  16   1                if(!P1_5)return 2;   //7
  17   1                if(!P1_6)return 3;   //8
  18   1                if(!P1_7)return 4;   //9
  19   1                if(!P3_6)return 5;   //X
  20   1                if(!P3_7)return 6;   //÷
  21   1                P1=0xfd;
  22   1                if(!P1_4)return 11; //+-
  23   1                if(!P1_5)return 12; //4
  24   1                if(!P1_6)return 13; //5
  25   1                if(!P1_7)return 14; //6
  26   1                if(!P3_6)return 15; //-
  27   1                if(!P3_7)return 16; //MRC
  28   1                P1=0xfb;
  29   1                if(!P1_4)return 21; //%
  30   1                if(!P1_5)return 22; //1
  31   1                if(!P1_6)return 23; //2
  32   1                if(!P1_7)return 24; //3
  33   1                if(!P3_6)return 25; //+
  34   1                if(!P3_7)return 26; //M-
  35   1                P1=0xf7;
  36   1                if(!P1_4)return 31; //□
  37   1                if(!P1_5)return 32; //0
  38   1                if(!P1_6)return 33; //.
  39   1                if(!P1_7)return 34; //=
  40   1                if(!P3_6)return 35; //+
  41   1                if(!P3_7)return 36; //M+
  42   1      
  43   1                P1=0xfF;P3_3=0;
  44   1                if(!P1_4)return 41; //
  45   1                if(!P1_5)return 42; //
  46   1                if(!P1_6)return 43; //
  47   1                if(!P1_7)return 44; //
  48   1                if(!P3_6)return 45; //
  49   1                if(!P3_7)return 46; //
  50   1                return 0;
  51   1      }
  52          
  53          void main(void) 
  54          {
  55   1        char key;
C51 COMPILER V8.08   MAIN                                                                  01/15/2008 19:44:27 PAGE 2   

  56   1        count = 0;
  57   1        Flag = 0;
  58   1        OP = 0;
  59   1        P3_4 = 1;
  60   1        EA = 1; //允许CPU中断 
  61   1        TMOD = 0x11; //设定时器0和1为16位模式1 
  62   1        ET0 = 1; //定时器0中断允许 
  63   1      
  64   1        P1=0xff;
  65   1        TH0 = 0xFF; 
  66   1        TL0 = 0xE6; //设定时值0为38K 也就是每隔26us中断一次  
  67   1        TR0 = 1;//开始计数
  68   1      
  69   1        iraddr1=0xff;
  70   1        iraddr2=0xff;
  71   1      
  72   1      
  73   1        do{
  74   2                key=getkey();
  75   2            if(key==1)SendIRdata(0x12);//set
  76   2            if(key==11)SendIRdata(0x0b);//exit
  77   2            if(key==25||key==35)SendIRdata(0x1a);//+
  78   2            if(key==15)SendIRdata(0x1e);//-
  79   2            if(key==6)SendIRdata(0x0e);//↑ ÷
  80   2            if(key==16)SendIRdata(0x1d);//↓ MRC
  81   2      
  82   2            if(key==26)SendIRdata(0x1f);//← M-
  83   2            if(key==36)SendIRdata(0x1b);//→ M+
  84   2            if(key==32)SendIRdata(0x00);//0
  85   2            if(key==22)SendIRdata(0x01);//1
  86   2            if(key==23)SendIRdata(0x02);//2
  87   2      
  88   2            if(key==24)SendIRdata(0x03);//3
  89   2            if(key==12)SendIRdata(0x04);//4
  90   2            if(key==13)SendIRdata(0x05);//5
  91   2            if(key==14)SendIRdata(0x06);//6
  92   2            if(key==2)SendIRdata(0x07);//7
  93   2            if(key==3)SendIRdata(0x08);//8
  94   2      
  95   2            if(key==4)SendIRdata(0x09);//9
  96   2            if(key==21)SendIRdata(0x2A);//%
  97   2            if(key==5)SendIRdata(0x2B);//X
  98   2            if(key==33)SendIRdata(0x2C);//.
  99   2            if(key==34)SendIRdata(0x2D);//=
 100   2            if(key==31)SendIRdata(0x2E);//□
 101   2      
 102   2            if(key==41)SendIRdata(0x2F);//
 103   2            if(key==42)SendIRdata(0x30);//
 104   2            if(key==43)SendIRdata(0x31);//
 105   2            if(key==44)SendIRdata(0x32);//
 106   2            if(key==45)SendIRdata(0x33);//
 107   2            if(key==46)SendIRdata(0x34);//
 108   2        }while(1);
 109   1      } 
 110          //定时器0中断处理 
 111          void timeint(void) interrupt 1 
 112          { 
 113   1        TH0=0xFF; 
 114   1        TL0=0xE6; //设定时值为38K 也就是每隔26us中断一次
 115   1        count++;
 116   1      
 117   1      } 
C51 COMPILER V8.08   MAIN                                                                  01/15/2008 19:44:27 PAGE 3   

 118          
 119          
 120          void SendIRdata(char p_irdata)
 121          {
 122   1        int i;
 123   1        char irdata=p_irdata;
 124   1      
 125   1        //发送9ms的起始码
 126   1        endcount=223;
 127   1        Flag=1;
 128   1        count=0;
 129   1        P3_4=0;
 130   1        do{}while(count<endcount);
 131   1      
 132   1        //发送4.5ms的结果码
 133   1        endcount=117;
 134   1        Flag=0;
 135   1        count=0;
 136   1        P3_4=1;
 137   1        do{}while(count<endcount);
 138   1      
 139   1        //发送十六位地址的前八位
 140   1        irdata=iraddr1;
 141   1        for(i=0;i<8;i++)
 142   1        {
 143   2      
 144   2           //先发送0.56ms的38KHZ红外波(即编码中0.56ms的低电平)
 145   2           endcount=10;
 146   2           Flag=1;
 147   2           count=0;
 148   2               P3_4=0;
 149   2           do{}while(count<endcount);
 150   2      
 151   2          //停止发送红外信号(即编码中的高电平)
 152   2           if(irdata-(irdata/2)*2)  //判断二进制数个位为1还是0
 153   2           {
 154   3             endcount=15;  //1为宽的高电平
 155   3           }
 156   2          else
 157   2           {
 158   3           endcount=41;   //0为窄的高电平
 159   3           }
 160   2          Flag=0;
 161   2          count=0;
 162   2              P3_4=1;
 163   2          do{}while(count<endcount);
 164   2      
 165   2          irdata=irdata>>1;
 166   2        }
 167   1      
 168   1        //发送十六位地址的后八位
 169   1        irdata=iraddr2;
 170   1        for(i=0;i<8;i++)
 171   1        {
 172   2           endcount=10;
 173   2           Flag=1;
 174   2           count=0;
 175   2               P3_4=0;
 176   2           do{}while(count<endcount);
 177   2      
 178   2           if(irdata-(irdata/2)*2)
 179   2           {
C51 COMPILER V8.08   MAIN                                                                  01/15/2008 19:44:27 PAGE 4   

 180   3              endcount=15;
 181   3           }
 182   2           else
 183   2           {
 184   3             endcount=41;
 185   3           }
 186   2           Flag=0;
 187   2           count=0;
 188   2               P3_4=1;
 189   2           do{}while(count<endcount);
 190   2      
 191   2           irdata=irdata>>1;
 192   2        }
 193   1      
 194   1        //发送八位数据
 195   1        irdata=~p_irdata;
 196   1        for(i=0;i<8;i++)
 197   1        {
 198   2           endcount=10;
 199   2           Flag=1;
 200   2           count=0;
 201   2               P3_4=0;
 202   2           do{}while(count<endcount);
 203   2      
 204   2           if(irdata-(irdata/2)*2)
 205   2           {
 206   3               endcount=15;
 207   3           }
 208   2           else
 209   2           {
 210   3             endcount=41;
 211   3           }
 212   2           Flag=0;
 213   2           count=0;
 214   2               P3_4=1;
 215   2           do{}while(count<endcount);
 216   2      
 217   2           irdata=irdata>>1;
 218   2        }
 219   1      
 220   1        //发送八位数据的反码
 221   1        irdata=p_irdata;
 222   1        for(i=0;i<8;i++)
 223   1        {
 224   2           endcount=10;
 225   2           Flag=1;
 226   2           count=0;
 227   2               P3_4=0;
 228   2           do{}while(count<endcount);
 229   2      
 230   2           if(irdata-(irdata/2)*2)
 231   2           {
 232   3               endcount=15;
 233   3           }
 234   2           else
 235   2           {
 236   3             endcount=41;
 237   3           }
 238   2           Flag=0;
 239   2           count=0;
 240   2               P3_4=1;
 241   2           do{}while(count<endcount);
C51 COMPILER V8.08   MAIN                                                                  01/15/2008 19:44:27 PAGE 5   

 242   2      
 243   2           irdata=irdata>>1;
 244   2        }
 245   1      
 246   1        endcount=10;
 247   1        Flag=1;
 248   1        count=0;
 249   1        P3_4=0;
 250   1       do{}while(count<endcount);
 251   1        P3_4=1;
 252   1        Flag=0;
 253   1      }
 254          
 255          void delay()
 256          {
 257   1        int i,j;
 258   1        for(i=0;i<400;i++)
 259   1        {
 260   2          for(j=0;j<100;j++)
 261   2          {
 262   3          }
 263   2        }
 264   1      }
 265          
 266          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1062    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      7       1
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -