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

📄 cap.lst

📁 用单片机来写的电压测试程序
💻 LST
字号:
C51 COMPILER V7.02b   CAP                                                                  06/11/2007 00:14:11 PAGE 1   


C51 COMPILER V7.02b, COMPILATION OF MODULE CAP
OBJECT MODULE PLACED IN cap.OBJ
COMPILER INVOKED BY: e:\Keil\C51\BIN\C51.EXE cap.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include"reg51.h"
   2          #include"51usb.h"                  
   3          
   4          #define  uchar unsigned char
   5          #define  uint  unsigned int
   6          
   7          /*************初始化定时器及计数器的函数*******************************/
   8          void initsys();
   9          void display();
  10          void delay1(uint ticks);
  11          
  12          void LCD_en_command(unsigned char command);//write command function
  13          void LCD_en_dat(unsigned char temp);//write data function
  14          
  15          //数据
  16          unsigned char code Tab[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};
  17          
  18          uchar index=0;
  19          uchar ShuMa[6]={0,0,0,0,0,0};//lcd缓冲区
  20          /////////////中断程序////////////////
  21          uint    i=4000;
  22          uchar bdata flag=0;
  23          sbit time_flag=flag^0;
  24          uint Frequency =0;
  25          unsigned long Frequency1 =0;
  26          uchar High=0;
  27          uchar Low=0;
  28          
  29          
  30          /***********************************************/
  31          void delay1(uint ticks)
  32          {
  33   1       uchar i;
  34   1       for(;ticks!=0;ticks--)for(i=100;i!=0;i--);
  35   1      }
  36          
  37          void ISR_Timer0() interrupt 1
  38          {//Timer0  中断服务程序;Timer0 内部时钟模式2
  39   1       //250us*4000=1000000us=1000ms=1s
  40   1       if(--i==0)
  41   1       {
  42   2        High= TH1;       //读取高位
  43   2        Low=TL1;         //读取低位
  44   2        TH1=0;
  45   2        TL1=0;
  46   2        time_flag=1;
  47   2        i=4000;
  48   2       }
  49   1      }
  50          /******************************电容测量的程序********************************/
  51          void cap()
  52          {
  53   1      
  54   1        
  55   1        display();                                    //刷新lcd
C51 COMPILER V7.02b   CAP                                                                  06/11/2007 00:14:11 PAGE 2   

  56   1        if(time_flag)                            //刷新显示缓冲区
  57   1        {
  58   2         Frequency=High;
  59   2         Frequency<<=8;
  60   2         Frequency+=Low;
  61   2        /***********************公式计算****************************/
  62   2         Frequency1=4800000/Frequency;
  63   2         /**********************************************************/
  64   2      
  65   2         ShuMa[5]=Frequency1%10;
  66   2         Frequency1/=10;
  67   2         ShuMa[4]=Frequency1%10;
  68   2         Frequency1/=10;
  69   2         ShuMa[3]=Frequency1%10;
  70   2         Frequency1/=10;
  71   2         ShuMa[2]=Frequency1%10;
  72   2         Frequency1/=10;
  73   2         ShuMa[1]=Frequency1%10;
  74   2         Frequency1/=10;
  75   2         ShuMa[0]=Frequency1%10;
  76   2         time_flag=0;
  77   2        }
  78   1       
  79   1      
  80   1      
  81   1      
  82   1      }
  83          
  84          void initsys()
  85          {
  86   1       TMOD=0x52;//Timer1外部计数,模式1(16位模式);Timer0 内部时钟模式2
  87   1       TH1=0;
  88   1       TL1=0;
  89   1       TH0=6;         //      Timer0  250us中断一次
  90   1       TL0=6;
  91   1      
  92   1       ET0=1;
  93   1       TF0=0;
  94   1       EA=1;
  95   1       TR0=1;
  96   1       TR1=1;
  97   1      }
  98          void display()
  99          {
 100   1       
 101   1      delay1(10);                                //延时
 102   1      LCD_en_command(0x84);
 103   1      LCD_en_dat(Tab[ShuMa[index]]);
 104   1      index++;
 105   1      delay1(10);
 106   1      
 107   1      LCD_en_command(0x85);
 108   1      LCD_en_dat(Tab[ShuMa[index]]);
 109   1      index++;
 110   1      delay1(10);
 111   1      
 112   1      LCD_en_command(0x86);
 113   1      LCD_en_dat(Tab[ShuMa[index]]);
 114   1      index++;
 115   1      delay1(10);
 116   1      
 117   1      LCD_en_command(0x87);
C51 COMPILER V7.02b   CAP                                                                  06/11/2007 00:14:11 PAGE 3   

 118   1      LCD_en_dat(Tab[ShuMa[index]]);
 119   1      index++;
 120   1      delay1(10);
 121   1      
 122   1      LCD_en_command(0x88);
 123   1      LCD_en_dat(Tab[ShuMa[index]]);
 124   1      index++;
 125   1      delay1(10);
 126   1      
 127   1      LCD_en_command(0x89);
 128   1      LCD_en_dat(Tab[ShuMa[index]]);
 129   1      index++;
 130   1      delay1(10);
 131   1      index=0;
 132   1      
 133   1      
 134   1      
 135   1      }
 136          
 137          


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