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

📄 main.lst

📁 这是本人花了200元买的51开发板上的所有程序资料
💻 LST
字号:
C51 COMPILER V8.02   MAIN                                                                  03/21/2008 22:23:26 PAGE 1   


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

line level    source

   1          #include "AT89x51.h"
   2          #include "string.h"
   3          #include "intrins.h"
   4          #include "DS1302.H"
   5          #include "LCD1602.H"
   6          
   7          unsigned char adj_time_flag; //0代表正常显示,1代表进入时间调整状态,相应位光标闪烁
   8          unsigned char shanshuo_flag; //光标闪烁标志
   9          unsigned char adj_time_section;
  10          unsigned char add_OR_dec_flag; //直加减标志位,0表示加,1表示减
  11          unsigned char time_count;
  12          unsigned char read_rtc_code[7];
  13          unsigned char read_rtc_address[7]={0x8d,0x89,0x87,0x8b,0x85,0x83,0x81};
  14          /********1ms延时子程序***********/
  15          delay_nms(unsigned int n)
  16          {
  17   1       unsigned int i;
  18   1       unsigned char j;
  19   1      
  20   1       for(i=0;i<n;i++)
  21   1          for(j=0;j<120;j++)
  22   1                ;     //空操作
  23   1      }
  24          void Read_RTC(void)    //读出DS1302里的相关信息,存放在read_rtd_code[]数组中
  25          {
  26   1       unsigned char i,*p;
  27   1       p=read_rtc_address; 
  28   1       for(i=0;i<7;i++)
  29   1       {
  30   2        read_rtc_code[i]=R1302(*p);
  31   2        p++;
  32   2       }
  33   1      }
  34          
  35          //时间显示程序
  36          void RTC_display(void)
  37          {
  38   1           Read_RTC();
  39   1           LCD_write_char(0,0x02,(read_rtc_code[0]/16)); //年十位
  40   1           LCD_write_char(0,0x03,(read_rtc_code[0]%16)); //年个位
  41   1           LCD_write_char(0,0x05,(read_rtc_code[1]/16)); //月十位
  42   1           LCD_write_char(0,0x06,(read_rtc_code[1]%16)); //月个位
  43   1           LCD_write_char(0,0x08,(read_rtc_code[2]/16)); //日十位
  44   1           LCD_write_char(0,0x09,(read_rtc_code[2]%16)); //日个位      // 因为定义时用16进制
  45   1      
  46   1               LCD_write_char(0,0x0f,(read_rtc_code[3]%16)); //星期
  47   1      
  48   1           LCD_write_char(1,0x05,(read_rtc_code[4]/16)); //时十位
  49   1           LCD_write_char(1,0x06,(read_rtc_code[4]%16)); //时个位
  50   1           LCD_write_char(1,0x08,(read_rtc_code[5]/16)); //分十位
  51   1           LCD_write_char(1,0x09,(read_rtc_code[5]%16)); //分个位
  52   1           LCD_write_char(1,0x0b,(read_rtc_code[6]/16)); //秒十位
  53   1           LCD_write_char(1,0x0c,(read_rtc_code[6]%16)); //秒个位
  54   1      }
  55          
C51 COMPILER V8.02   MAIN                                                                  03/21/2008 22:23:26 PAGE 2   

  56          
  57          
  58          //时间调整显示程序
  59          void adj_time_display(void)
  60          {
  61   1       Read_RTC();
  62   1       switch(adj_time_section)
  63   1          {// write_lcd_command(0x83);
  64   2           case 0x01:
  65   2             if(shanshuo_flag==1)
  66   2              lcd_displaystr(0,0x02,"  ");
  67   2                 else
  68   2               RTC_display();break; 
  69   2          
  70   2           case 0x02:
  71   2             if(shanshuo_flag==1)
  72   2              lcd_displaystr(0,0x05,"  ");
  73   2                 else
  74   2               RTC_display(); break;
  75   2            case 0x03:
  76   2              if(shanshuo_flag==1)
  77   2                lcd_displaystr(0,0x08,"  ");
  78   2                  else
  79   2                RTC_display();break;
  80   2            case 0x04:
  81   2              if(shanshuo_flag==1)
  82   2                lcd_displaystr(0,0x0f," ");
  83   2                  else
  84   2                RTC_display();break;
  85   2            case 0x05:
  86   2              if(shanshuo_flag==1)
  87   2               lcd_displaystr(1,0x05,"  ");
  88   2                  else
  89   2                RTC_display();break;
  90   2            case 0x06:
  91   2              if(shanshuo_flag==1)
  92   2                lcd_displaystr(1,0x08,"  ");
  93   2                  else
  94   2                RTC_display();break;
  95   2            case 0x07:
  96   2              if(shanshuo_flag==1)
  97   2                lcd_displaystr(1,0x0b,"  ");
  98   2                  else
  99   2                RTC_display();break;
 100   2               default:break;
 101   2               
 102   2               }
 103   1      }
 104          
 105          void system_initial(void)
 106          {
 107   1       initial_lcd1602(); //初始化LCD1602
 108   1      }
 109          void main(void)
 110          {
 111   1        TMOD=0X01;//使用定时器0,16位定时
 112   1        TH0=(65535-50000)/256;
 113   1        TL0=(65535-50000)%256;
 114   1        ET0=1;
 115   1        EA=1;
 116   1        system_initial();
 117   1        delay_nms(10);
C51 COMPILER V8.02   MAIN                                                                  03/21/2008 22:23:26 PAGE 3   

 118   1        delay_nms(10);
 119   1       
 120   1        //输出显示
 121   1        W1302(0x90,0xa5);//打开充电二级管  一个二级管串联一个2K电阻 
 122   1        W1302(0x8e,0x80);//写保护,禁止写操作  
 123   1       
 124   1         {
 125   2        lcd_displaystr(0,0x00,"20");
 126   2        delay_nms(10);
 127   2        lcd_displaystr(0,0x04,"-");
 128   2        delay_nms(10);
 129   2        lcd_displaystr(0,0x07,"-");
 130   2        lcd_displaystr(0,0x0b,"Week:");
 131   2        lcd_displaystr(1,0x00,"Time ");
 132   2        lcd_displaystr(1,0x07,":");
 133   2        lcd_displaystr(1,0x0a,":");
 134   2         }
 135   1       while(1)
 136   1         {
 137   2          //按键扫描程序
 138   2           if(P2_0==0)
 139   2              {
 140   3                delay_nms(10);
 141   3                if(P2_0==0)
 142   3                  {
 143   4                                TR0=1;
 144   4                    adj_time_section++;   //光标移位
 145   4                                if(adj_time_section==8)
 146   4                                 {adj_time_section=0;TR0=0;}
 147   4                    while(P2_0==0);
 148   4                  }
 149   3              }
 150   2           if(P2_1==0)  //加按键
 151   2              {
 152   3                delay_nms(10);
 153   3                if(P2_1==0)
 154   3                  {
 155   4                    add_OR_dec_flag=0;
 156   4                    Set(adj_time_section,add_OR_dec_flag);//调用时间调整子程序,此程序在DS1302.H文件中
 157   4                    while(P2_1==0);
 158   4                  }
 159   3              }
 160   2           if(P2_2==0)
 161   2              {
 162   3                delay_nms(10);
 163   3                if(P2_2==0)
 164   3                  {
 165   4                                
 166   4                                add_OR_dec_flag=1;
 167   4                    Set(adj_time_section,add_OR_dec_flag);//调用时间调整子程序,此程序在DS1302.H文件中
 168   4                    while(P2_2==0);
 169   4                  }
 170   3              }
 171   2      
 172   2      
 173   2      
 174   2      
 175   2          if(adj_time_section==0)//正常时间显示
 176   2                 RTC_display();
 177   2              else                  //时间调整时候时间显示
 178   2                adj_time_display();
 179   2      
C51 COMPILER V8.02   MAIN                                                                  03/21/2008 22:23:26 PAGE 4   

 180   2          
 181   2         }
 182   1        
 183   1      }
 184          
 185          void t0_ovf(void) interrupt 1   //中断主要是位在时间调整的时候,调整相应位会闪烁
 186          {
 187   1       
 188   1        TH0=(65535-50000)/256;
 189   1        TL0=(65535-50000)%256;
 190   1        time_count++;
 191   1        if(time_count==10)
 192   1           shanshuo_flag=1;
 193   1        if(time_count==20)
 194   1          {time_count=0;shanshuo_flag=0;}
 195   1        
 196   1      }


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


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

⌨️ 快捷键说明

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