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

📄 main.lst

📁 单片机程序举例
💻 LST
字号:
C51 COMPILER V8.02   MAIN                                                                  03/06/2009 00:48:02 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /**************************************************************************
   2          * 文 件 名:main.c
   3          * 功    能:万年历( 公历加农历),键盘输入,电子钢琴
   4          * 作    者:张聪
   5          **************************************************************************/
   6          /****************************文件包含*************************************/
   7          #include < at89x52.h >
   8          #include < character.h >
   9          #include < lcd.h >
  10          #include < clock.h >
  11          #include < sensor.h>
  12          #include < calendar.h >
  13          #include < key.h >
  14          /*****************************预定义**************************************/
  15          #define uchar unsigned char
  16          #define uint unsigned int
  17          unsigned char hi_note,low_note;
  18          unsigned char STH0; 
  19          unsigned char STL0;
  20          uchar ID=0;
  21          unsigned char lastop;
  22          unsigned long result=0;
  23          unsigned long currentvalue=0,lastvalue=0;
  24          /**********************************************************************
  25          **                                                              函数申明                                                         **
  26          **********************************************************************/
  27          void display(int);
  28          unsigned char key_scan(void);
  29          unsigned char transition(unsigned char);
  30          bit isdigit(unsigned char );
  31          unsigned int process(unsigned char );
  32          uchar input1();
  33          
  34           /****************************************************************************
  35           数组功能:计算器键盘定义
  36          ****************************************************************************/
  37          unsigned  char code keyvalue[]=
  38          {
  39          '7','8','9','/',
  40          '4','5','6','*',
  41          '1','2','3','-',
  42          'o','0','=','+'
  43          };
  44          /****************************************************************************
  45           数组功能:自定义歌曲
  46          ****************************************************************************/
  47          code unsigned song[]={
  48          0xfc,0xd1,0xc1,0xb1,0xc1, 0xd4,0xc1,0xd1,0xf1,0xc1,0xd6,0xc1,0xd1, 0xcc,0x01,0xc1,0xb1,0x91,0x81, 0x94,0x8
             -1,0x91,0xb1,0x81,0x98, 
  49          0x86,0x62,0x84,0xb2,0xc2, 0xd6,0xc1,0xd1,0xf6,0xd2, 0xc6,0xc2,0x01,0xc2,0xc2,0xb2,0x92,0xb8,0x41,0x51,0x61
             -,0x51,0x61,0x81,0x41,0x51,
  50          0x62,0xd4,0x01,0xd2,0x01,0xd8, 0xc2,0xc1,0xd1,0xd2,0xc2,0xb4,0x92,0x82, 0x66,0x52,0x42,0xb2,0xb2,0x92, 0x8
             -8,0x01,0x81,0x61,0x84,0x01,0x82,
  51          0x92,0xb2,0xb2,0x92,0xb4,0xc1,0xb1,0x91,0x81, 0x62,0x82,0x82,0x81,0x91,0x84,0x42,0x52, 0x62,0x82,0x82,0xb2
             -,0x92,0x82,0x62,0x52, 0x46,0xb2,0x92,0x82,0x61,0x51,0x42,
C51 COMPILER V8.02   MAIN                                                                  03/06/2009 00:48:02 PAGE 2   

  52          0x56,0x82,0x82,0x62,0x62,0x52, 0x42,0x42,0x52,0x62,0x86,0x01,0x82, 0x62,0x82,0x82,0xb2,0xb2,0xc2,0xc2,0xc2
             -,0xc1,0xd1, 0xcf,
  53          0xb6,0xc2,0xd4,0xc2,0xb2, 0x92,0xb2,0xb2,0x92,0x84,0x64,0x01, 0x66,0x82,0x81,0x91,0x82,0x61,0x51,0x42, 0x5
             -c,0x62,0x82,
  54          0x86,0x92,0x82,0x62,0x84, 0x92,0xb2,0xb2,0xc2,0xd8, 0xc6,0x01,0xc2,0xc2,0xc2,0xb2,0x91,0xb1, 0xbf,0x01, 0x
             -bf,0x00};
  55          code int note[]={
  56          0x0000,0xFB03,0xFB8E,0xFC0B,0xFC43,0xFCAB,0xFD08,0xFD32,                                 
  57          0xFD81,0xFDC7,0xFE05,0xFE21,0xFE55,0xFE83,0xFE99,0xFEC0};
  58          /****************************************************************************
  59           数组功能:定义音节频率低音3到高音7
  60          ****************************************************************************/
  61          unsigned int code tab[32]={64021,64103,64185,64260,64331,64400,64463,64524,
  62                                                             64580,64633,64684,64732,64777,64820,64860,64898,
  63                                                             64934,64968,64994,65030,65058,65085,65110,65134,
  64                                                             65157,65178,65198,65217,65235,65252,65268,65283};
  65          code ksp[8]={0x8F,0x9F,0xAF,0xBF,0xCF,0xDF,0xEF,0xFF};
  66          /****************************************************************************
  67           数组功能:定义  按键按下时 P2口的数据
  68          ****************************************************************************/
  69          code key_code1[32]={142,206,174,238,158,222,190,254,
  70                              141,205,173,237,157,221,189,253,
  71                                              139,203,171,235,155,219,187,251,
  72                                                  135,199,167,231,151,215,183,247};
  73          
  74          /****************************************************************************/
  75          sbit in = P0 ^ 2 ;// 定义闹钟停止端口
  76          sbit cut = P0 ^ 4;//功能切换端口
  77          sbit bell = P0 ^ 5; //定义蜂鸣器端口
  78          /*****************************************************************************
  79          * 名称: timer1_isr(void) inturrupt 2
  80          * 功能:
  81          * 入口参数:
  82          * 出口参数:
  83          *****************************************************************************/
  84          void calendar();
  85          void singing();
  86          static void timer1_isr(void) interrupt TF1_VECTOR using 2
  87          {
  88   1         TR1=0;
  89   1         TL1=low_note;
  90   1         TH1=hi_note;
  91   1         TR1=1;
  92   1         bell=~bell;
  93   1      }
  94           /*****************************************************************************
  95          * 名称: timer1_initialize() inturrupt 0
  96          * 功能:
  97          * 入口参数:
  98          * 出口参数:
  99          *****************************************************************************/              
 100          static void timer1_initialize(void)
 101          {
 102   1         EA=0;
 103   1         TR1=0;
 104   1         TMOD = 0X10;
 105   1         ET1=1;
 106   1         EA=1;
 107   1      }
 108          /*****************************************************************************
 109          * 名称: Timer0_Service() inturrupt 0
 110          * 功能:
C51 COMPILER V8.02   MAIN                                                                  03/06/2009 00:48:02 PAGE 3   

 111          * 入口参数:
 112          * 出口参数:       
 113          *****************************************************************************/
 114          void t0(void) interrupt 1 using 0
 115          { 
 116   1        TH0=STH0;
 117   1        TL0=STL0; 
 118   1        bell=~bell;
 119   1      }
 120          /*****************************************************************************
 121          * 名称: void switcch()
 122          * 功能:功能选择键钮
 123          * 入口参数:
 124          * 出口参数:
 125          /*****************************************************************************/
 126          void switcch()
 127           {       void calendar();
 128   1           void input();
 129   1               void piano();
 130   1               void singsong();
 131   1               void calculator(); 
 132   1             switch(ID) 
 133   1              { case 0: 
 134   2                              {Lcd_Clear();
 135   3                   calendar();break;} 
 136   2                               case 1: 
 137   2                 {Lcd_Clear();
 138   3                   calculator();break;} 
 139   2                        case 2: 
 140   2                 {Lcd_Clear();
 141   3                  piano();break;}
 142   2                         case 3: 
 143   2                 {Lcd_Clear();
 144   3                   input();break;}
 145   2                       case 4: 
 146   2                 {Lcd_Clear();
 147   3                   singsong();break;}
 148   2                        
 149   2                }
 150   1       }   
 151          /******************************************************************************
 152          * 函数名称

⌨️ 快捷键说明

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