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

📄 mainfile.lst

📁 多功能智能充电器
💻 LST
字号:
C51 COMPILER V8.02   MAINFILE                                                              05/20/2008 10:43:29 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE MAINFILE
OBJECT MODULE PLACED IN mainfile.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE src\mainfile.c BROWSE DEBUG OBJECTEXTEND PRINT(.\mainfile.lst) OBJECT(mainf
                    -ile.obj)

line level    source

   1          #include "reg5410.h"
   2          #include "head.h"
   3          
   4          
   5          extern void InitLCD();
   6          
   7          
   8          extern unsigned char read(unsigned char ADDRH,unsigned char ADDRL);
   9          extern void write(unsigned char ADDRH,unsigned char *p,unsigned char k);
  10          extern void DispShuzi0(unsigned char x,unsigned char y,unsigned int n);  //8*16数字显示
  11          extern void DispShuzi(unsigned char x,unsigned char y,unsigned int n);   //8*16数字显示
  12          extern void DispShuzi1(unsigned char x,unsigned char y,unsigned int n);  //8*16数字显示
  13          extern void DispShuzi2(unsigned char x,unsigned char y,unsigned int n);  //8*16数字显示
  14          extern void DispZimu(unsigned char x,unsigned char y,unsigned char how,unsigned char *stri);
  15          extern void DispHanzi(unsigned char x,unsigned char y,unsigned char how,unsigned char *stri);
  16          extern void send_command(unsigned char command_data) ;
  17          
  18          
  19          void System_init(void);
  20          void Disp_Page0(void);
  21          void Disp_Page1(void);
  22          void Disp_Page2(void);
  23          void Disp_Page3(void);
  24          void GetADCaiJiDL(unsigned int *ADData);
  25          void GetADCaiJiDY(unsigned int *ADData);
  26          void jiemian(void);
  27          
  28          unsigned char dat[2];
  29          unsigned int Sec;
  30          unsigned int Min;
  31          unsigned char ti=0,page=0;
  32          
  33          main()
  34          {       
  35   1              Sec=0;Min=0;page=0;
  36   1      //      dat[0]=Sec/256;dat[1]=Sec%256;write(0x28,dat,2);
  37   1      //      dat[0]=Min/256;dat[1]=Min%256;write(0x2a,dat,2); 
  38   1              InitLCD();
  39   1              Disp_Page0();
  40   1              System_init();
  41   1              while(1)
  42   1              {
  43   2                      jiemian();
  44   2              }
  45   1      }
  46          void System_init(void)
  47          {
  48   1              TMOD=0x21;
  49   1              TH0=0xee;
  50   1              TL0=0x00;
  51   1              TH1=TL1=0xfd;
  52   1              SCON=0x50;
  53   1              REN=1;
  54   1              CMOD=0x00;
C51 COMPILER V8.02   MAINFILE                                                              05/20/2008 10:43:29 PAGE 2   

  55   1              ET0=1;
  56   1              EA=1;
  57   1              P1M0=0x02;
  58   1              P1M1=0x00;
  59   1              ADC_CONTR =0x81;
  60   1              TR0=1;TR1=1;
  61   1      }
  62          
  63          
  64          void inte(void) interrupt 1
  65          {
  66   1              static unsigned int t=0;
  67   1              TH0=0xee;
  68   1              TL0=0x00;
  69   1      
  70   1              if(++t==200)
  71   1              {
  72   2                      t=0;
  73   2      //              dat[0]=Sec/256;dat[1]=Sec%256;write(0x28,dat,2);
  74   2                      if(++Sec>59)
  75   2                      {
  76   3                              Sec=0;
  77   3                              Min++;
  78   3      //                      dat[0]=Min/256;dat[1]=Min%256;write(0x2a,dat,2); 
  79   3                      }
  80   2              }
  81   1      //      if(page==1)
  82   1      //      DispShuzi0(3,6,Sec);     
  83   1      }
  84          
  85          void jiemian(void)
  86          {
  87   1              unsigned int tmpDL=0,tmpDY=0,S=0;
  88   1              GetADCaiJiDL(&tmpDL);
  89   1              GetADCaiJiDY(&tmpDY);   //电压代码每100代表实际电压0.6V
  90   1      
  91   1              if(tmpDY<=700&&page!=0)                  
  92   1                      {page=0;Disp_Page0();}
  93   1              else if(tmpDY>=900&&page!=2)
  94   1                      {page=2;Disp_Page2();}
  95   1              else if(tmpDY>700&&tmpDY<900&&page!=1)
  96   1                      {page=1;Disp_Page1();}
  97   1      
  98   1              if(page==1)
  99   1              {        
 100   2                      
 101   2                       DispShuzi(2,4,tmpDL/16);
 102   2                       DispShuzi(1,4,tmpDY);
 103   2                       DispShuzi0(3,6,Sec);
 104   2                       DispShuzi0(3,4,Min);
 105   2                       S=Sec%5;
 106   2                       if(S==0)
 107   2                              DispHanzi(0,4,4,"□□□□");
 108   2                       else if(S==1)
 109   2                              DispHanzi(0,4,2,"■□□□");
 110   2                       else if(S==2)
 111   2                              DispHanzi(0,4,4,"■■□□");
 112   2                       else if(S==3)
 113   2                              DispHanzi(0,4,4,"■■■□");
 114   2                       else if(S==4)
 115   2                              DispHanzi(0,4,4,"■■■■");
 116   2              }         
C51 COMPILER V8.02   MAINFILE                                                              05/20/2008 10:43:29 PAGE 3   

 117   1      }
 118          
 119          void Disp_Page0(void)
 120          {               
 121   1              send_command(0x01);
 122   1              DispHanzi(0,0,5,"多功能智能");
 123   1              DispHanzi(1,0,5,"电池充电器");
 124   1      }
 125          
 126          void Disp_Page1(void)
 127          {
 128   1              unsigned int td=0;
 129   1              send_command(0x01);
 130   1              DispHanzi(0,0,4,"充电中■");
 131   1              DispHanzi(1,0,4,"充电电压");
 132   1                      DispZimu(1,7,1,"V");
 133   1              DispHanzi(2,0,4,"充电电流");
 134   1                      DispZimu(2,7,1,"A");
 135   1              DispHanzi(3,0,4,"充电时间");
 136   1      //              td=read(0x2a,0x00);Min=td*256+read(0x2a,0x01);
 137   1      //                      DispShuzi0(3,4,Min);
 138   1                      
 139   1      //              td=read(0x28,0x00);Sec=td*256+read(0x28,0x01);
 140   1      //                      DispShuzi0(3,6,Sec);
 141   1                              DispHanzi(3,5,1,"分");
 142   1                              DispHanzi(3,7,1,"秒");
 143   1      }       
 144          
 145          void Disp_Page2(void)
 146          {
 147   1              send_command(0x01);
 148   1              DispHanzi(0,0,4,"充电完成");
 149   1      }
 150          
 151          
 152          void Disp_Page3(void)
 153          {
 154   1              send_command(0x01);
 155   1              DispHanzi(0,0,5,"电池被移除" );
 156   1              DispHanzi(1,0,4,"充电中止");
 157   1      }
 158          
 159          
 160          void GetADCaiJiDL(unsigned int *ADData)
 161          {
 162   1              unsigned int i, j, Sum;
 163   1              ADC_CONTR=0x80|0x05;
 164   1              for(i=0; i<100; i++);
 165   1              Sum = 0;
 166   1              for(i=0; i<64; i++)
 167   1              {
 168   2                      ADC_CONTR|=0x08;
 169   2                      while((ADC_CONTR&0x10)==0x00);                  //等待变成flag=1
 170   2                      Sum = Sum + (ADC_DATA*4+ADC_LOW2);
 171   2                      for(j=0; j<100;j++);
 172   2              }
 173   1              *ADData =Sum/64;
 174   1      }
 175          
 176          void GetADCaiJiDY(unsigned int *ADData)
 177          {
 178   1              unsigned int i, j, Sum;
C51 COMPILER V8.02   MAINFILE                                                              05/20/2008 10:43:29 PAGE 4   

 179   1              ADC_CONTR=0x80|0x06;
 180   1              for(i=0; i<100; i++);
 181   1              Sum = 0;
 182   1              for(i=0; i<64; i++)
 183   1              {
 184   2                      ADC_CONTR|=0x08;
 185   2                      while((ADC_CONTR&0x10)==0x00);                  //等待变成flag=1
 186   2                      Sum = Sum + (ADC_DATA*4+ADC_LOW2);
 187   2                      for(j=0; j<100;j++);
 188   2              }
 189   1              *ADData =Sum/64;
 190   1      }         


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    906    ----
   CONSTANT SIZE    =    142    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     10      14
   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 + -