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

📄 void.lst

📁 红外线控制媒体播放程序
💻 LST
字号:
C51 COMPILER V8.02   VOID                                                                  04/27/2008 15:48:32 PAGE 1   


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

line level    source

   1          #include <at892051.h>
   2          
   3          sbit STA_4094 = P1^5;      //4094起动
   4          sbit CLK_4094 = P1^3;      //4094时钟
   5          sbit DATA_4094= P1^4;      //4094数据
   6          sbit LED1     = P1^6;      //LED1使能
   7          sbit LED2     = P1^7;      //LED2使能
   8          sbit INFR     = P1^1;      //红外输入
   9          
  10          #define uchar      unsigned char
  11          #define uint       unsigned int
  12          
  13          uchar code str[]={0xff,0x3a,0xfc,0x60,0xda,0x2a,0x8e};  //8. ,d  ,0  ,1  ,2  ,n  ,f
  14          uchar senddata,flag;
  15          
  16          void fun_all();                    //LED全亮
  17          void fun_d1();                     //LED显示d1
  18          void fun_d2();                     //LED显示d2
  19          void fun_on();                     //LED显示on
  20          void fun_of();                     //LED显示of
  21          void delay(uchar k);       //延时
  22          void fun_send();                   //串行数据发送
  23          infrared();                                //红外解码
  24          lead();                                    //起始码
  25          data_code();               //读码值
  26          void main()
  27           {
  28   1        fun_all();
  29   1      
  30   1       }
  31           void fun_all()
  32           {
  33   1            LED1 = 1;
  34   1                LED2 = 0;
  35   1        senddata = str[0];
  36   1          fun_send();
  37   1               delay(50);
  38   1            LED2 = 1;
  39   1                LED1 = 0;
  40   1        senddata = str[0];
  41   1          fun_send();
  42   1       }
  43           void fun_d1()
  44           {
  45   1            LED1 = 1;
  46   1                LED2 = 0;
  47   1        senddata = str[1];
  48   1          fun_send();
  49   1           delay(50);
  50   1                LED2 = 1;
  51   1                LED1 = 0;
  52   1        senddata = str[3];
  53   1          fun_send();
  54   1       }
  55           void fun_d2()
C51 COMPILER V8.02   VOID                                                                  04/27/2008 15:48:32 PAGE 2   

  56           {
  57   1            LED1 = 1;
  58   1                LED2 = 0;
  59   1        senddata = str[1];
  60   1          fun_send();
  61   1           delay(50);
  62   1                LED2 = 1;
  63   1                LED1 = 0;
  64   1        senddata = str[4];
  65   1        fun_send();
  66   1       }
  67           void fun_on()
  68           {
  69   1            LED1 = 1;
  70   1                LED2 = 0;
  71   1        senddata = str[2];
  72   1          fun_send();
  73   1               delay(50);
  74   1            LED2 = 1;
  75   1                LED1 = 0;
  76   1        senddata = str[5];
  77   1          fun_send();
  78   1       }
  79           void fun_of()
  80           {
  81   1            LED1 = 1;
  82   1                LED2 = 0;
  83   1        senddata = str[2];
  84   1          fun_send();
  85   1               delay(50);
  86   1            LED2 = 1;
  87   1                LED1 = 0;
  88   1        senddata = str[6];
  89   1          fun_send();
  90   1       }
  91          void delay(uchar k)
  92          {
  93   1         uchar i;
  94   1         for(i=0;i<k;i++)
  95   1         { ; }
  96   1      }
  97          void fun_send() // 移位传送
  98          {
  99   1              uchar i;
 100   1           for (i=0; i<=7; i++)
 101   1              {
 102   2                        STA_4094 = 1;
 103   2                                delay(100);
 104   2                                CLK_4094 = 1;
 105   2                                delay(10);
 106   2                                CLK_4094 =0;
 107   2                                if (senddata & 0x80)  
 108   2                                   DATA_4094 = 1; 
 109   2                                else 
 110   2                                    DATA_4094 = 0;
 111   2                        senddata <<= 1;
 112   2                    delay(3);
 113   2                                CLK_4094 = 1;
 114   2                                STA_4094 = 0;
 115   2                    delay(5);
 116   2              }
 117   1      }
C51 COMPILER V8.02   VOID                                                                  04/27/2008 15:48:32 PAGE 3   

 118          
 119          infrared()         //红外解码
 120          {
 121   1       lead();
 122   1       if(flag)
 123   1       data_code();
 124   1       //开发中......
 125   1      }
 126          lead()
 127          {
 128   1       begain:
 129   1              INFR=0;
 130   1              if(INFR==1)
 131   1                {
 132   2                 TMOD = 0x01;
 133   2                     TH0 = 0xDC;
 134   2                     TL0 = 0xD8;
 135   2                     TR0 = 1;
 136   2                }
 137   1              if(TF0==1)
 138   1                {if(INFR==0)
 139   2                       {
 140   3                            TH0 = 0xee;
 141   3                        TL0 = 0x6c;
 142   3                        TR0 = 1;
 143   3                       }
 144   2                         else
 145   2                             goto begain;
 146   2                         if(TF0==1)
 147   2                           if(INFR==1)
 148   2                                  flag = 1;
 149   2                               else
 150   2                                   goto begain;
 151   2                        }
 152   1                  else
 153   1                      goto begain;
 154   1      }
 155          data_code()
 156          {
 157   1        uchar temp = 0;
 158   1        uchar temp1 = 0;
 159   1        uchar BitCounter = 8;
 160   1        INFR = 1;
 161   1        do{
 162   2           if(INFR)                             /*如果INFR=1;*/
 163   2             temp=temp|0x01;                     /*temp的最低位置1*/
 164   2           else
 165   2             temp=temp&0xfe;                     /*否则temp的最低位清0*/
 166   2           if(BitCounter-1)
 167   2             { 
 168   3                   temp1=temp<<1;
 169   3               temp=temp1;
 170   3             } 
 171   2           BitCounter--;
 172   2          }
 173   1        while(BitCounter);
 174   1        return(temp);
 175   1      }
 176          


MODULE INFORMATION:   STATIC OVERLAYABLE
C51 COMPILER V8.02   VOID                                                                  04/27/2008 15:48:32 PAGE 4   

   CODE SIZE        =    293    ----
   CONSTANT SIZE    =      7    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      2    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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