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

📄 ht1621.lst

📁 单体电容测试仪源码程序 可测电压、有A/D转换等。
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.06   HT1621                                                                02/13/2009 09:29:11 PAGE 1   


C51 COMPILER V8.06, COMPILATION OF MODULE HT1621
OBJECT MODULE PLACED IN ht1621.OBJ
COMPILER INVOKED BY: c:\Keil\C51\BIN\C51.EXE ht1621.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <intrins.h>
   2          #include "SM5964reg.h"
   3          #include "ht1621.h"
   4          #include "NewType.h"
   5          #include "OS_CFG.H"
   6          
   7          
   8          sbit HT1621SCL  = P0^0;
   9          sbit HT1621DATA = P0^1;
  10          sbit HT1621CS1 = P0^2;
  11          sbit HT1621CS2 = P0^3;
  12          
  13          bit RefreshDisplay;
  14          unsigned char idata m_DisplayDriveBuf[2][16];
  15          
  16          extern unsigned long ADC_counter;               //adc计数
  17          
  18          
  19          //  液晶和HT1621对应表
  20          //            A
  21          //               ---   
  22          //          F   | G |  B
  23          //               ---   
  24          //          E   |   |  C
  25          //               ---   
  26          //            D
  27          
  28          //  新主板第1种的字模表                 //  新主板第2种的字模表                   
  29          //  字模表和液晶屏上实际的位置对应              //  字模表和液晶屏上实际的位置对应    
  30          //  根据实际的连线调整了次序,p为特殊段  //  根据实际的连线调整了次序,p为特殊段                            
             -    
  31          //       P C B A  D E G F                       //       A B C P  F G E D           
  32          //  0 FD 1 1 1 1  1 1 0 1                               //  0 FB 1 1 1 1  1 0 1 1           
  33          //  1 E0 1 1 1 0  0 0 0 0                               //  1 70 0 1 1 1  0 0 0 0           
  34          //  2 BE 1 0 1 1  1 1 1 0                               //  2 D7 1 1 0 1  0 1 1 1           
  35          //  3 FA 1 1 1 1  1 0 1 0                               //  3 F5 1 1 1 1  0 1 0 1           
  36          //  4 E3 1 1 1 0  0 0 1 1                               //  4 7C 0 1 1 1  1 1 0 0           
  37          //  5 DB 1 1 0 1  1 0 1 1                               //  5 BD 1 0 1 1  1 1 0 1           
  38          //  6 DF 1 1 0 1  1 1 1 1                               //  6 BF 1 0 1 1  1 1 1 1           
  39          //  7 F0 1 1 1 1  0 0 0 0                               //  7 F0 1 1 1 1  0 0 0 0           
  40          //  8 FF 1 1 1 1  1 1 1 1                               //  8 FF 1 1 1 1  1 1 1 1           
  41          //  9 FB 1 1 1 1  1 0 1 1                               //  9 FD 1 1 1 1  1 1 0 1           
  42          //  - 82 1 0 0 0  0 0 1 0                               //  - 14 0 0 0 1  0 1 0 0           
  43          //  A F7 1 1 1 1  0 1 1 1                               //  A FE 1 1 1 1  1 1 1 0           
  44          //  B CF 1 1 0 0  1 1 1 1                               //  B 3F 0 0 1 1  1 1 1 1           
  45          //  C 9D 1 0 0 1  1 1 0 1                               //  C 9B 1 0 0 1  1 0 1 1           
  46          //  D EE 1 1 1 0  1 1 1 0                               //  D 77 0 1 1 1  0 1 1 1           
  47          //  E 9F 1 0 0 1  1 1 1 1                               //  E 9F 1 0 0 1  1 1 1 1           
  48          //  F 97 1 0 0 1  0 1 1 1                       //  F 9E 1 0 0 1  1 1 1 0           
  49          //  N F5 1 1 1 1  0 1 0 1                               //  N FA 1 1 1 1  1 0 1 0           
  50          //  L 8D 1 0 0 0  1 1 0 1                               //  L 1B 0 0 0 1  1 0 1 1           
  51          //  K 8F 1 0 0 0  1 1 1 1                               //  K 1F 0 0 0 1  1 1 1 1           
  52          //  o CE 1 1 0 0  1 1 1 1                               //  o 37 0 0 1 1  0 1 1 1           
  53          //  r 86 1 0 0 0  0 1 1 0                               //  r 16 0 0 0 1  0 1 1 0           
  54          //  P B7 1 0 1 1  0 1 1 1                               //  P DE 1 1 0 1  1 1 1 0           
C51 COMPILER V8.06   HT1621                                                                02/13/2009 09:29:11 PAGE 2   

  55          //  H E7 1 1 1 0  0 1 1 1                               //  H 7E 0 1 1 1  1 1 1 0           
  56          //  U ED 1 1 1 0  1 1 0 1                               //  U 7B 0 1 1 1  1 0 1 1           
  57          //  J DB 1 1 1 0  1 0 0 0                               //  J BD 0 1 1 1  0 0 0 1           
  58          //************************************************************************
  59          //  第1种的字模表
  60          unsigned char code FontTab1[ 27 ]=
  61          //         0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F   10 11(-) 12(N) 13(|
             -_) 14(o)  15(r) 16(P) 17(H) 18(U) 19(J) 1A(K)
  62                          {0xFD,0xE0,0xBE,0xFA,0xE3,0xDB,0xDF,0xF0,0xFF,0xFB,0xF7,0xCF,0x9D,0xEE,0x9F,0x97,0x80,0x82,0xF5,  0x8D  
             -,0xCE, 0x86, 0xB7, 0xE7, 0xED, 0xE8,0x8F};
  63          //  第2种的字模表
  64          unsigned char code FontTab2[ 27 ]=
  65          //         0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F   10  11(-) 12(N) 13(
             -|_) 14(o) 15(r) 16(P) 17(H) 18(U) 19(J) 1A(K)
  66                          {0xFB,0x70,0xD7,0xF5,0x7C,0xBD,0xBF,0xF0,0xFF,0xFD,0xFE,0x3F,0x9B,0x77,0x9F,0x9E,0x10,0x14, 0xFA, 0x1B  
             -,0x37, 0x16, 0xDE, 0x7E, 0x7B, 0x71,0x1f};
  67          //************************************************************************
  68          
  69          
  70          
  71          
  72          //向HT1621发时钟。
  73          void HT1621Clk(void)
  74          {
  75   1              HT1621SCL = 0;
  76   1              _nop_();
  77   1              _nop_();
  78   1              _nop_();
  79   1      
  80   1      
  81   1              HT1621SCL = 1;
  82   1              _nop_();
  83   1              _nop_();
  84   1              _nop_();
  85   1              _nop_();
  86   1              _nop_();
  87   1              _nop_();
  88   1              _nop_();
  89   1              _nop_();
  90   1              _nop_();
  91   1              _nop_();
  92   1      
  93   1              _nop_();
  94   1              _nop_();
  95   1              _nop_();
  96   1              _nop_();
  97   1              _nop_();
  98   1              _nop_();
  99   1              _nop_();
 100   1              _nop_();
 101   1              _nop_();
 102   1              _nop_();
 103   1              HT1621SCL = 0;
 104   1      }
 105            
 106          //送一个字节的命令。
 107          void SendCommand(unsigned char Cmd)
 108          {
 109   1              unsigned char i;
 110   1              for(i=0;i<9;i++) {
 111   2                      HT1621DATA = (bit)(Cmd & 0x80);
 112   2                      HT1621Clk();
C51 COMPILER V8.06   HT1621                                                                02/13/2009 09:29:11 PAGE 3   

 113   2                      Cmd <<= 1;
 114   2              }
 115   1      }
 116            
 117          //送一个字节的数据。
 118          void SendOneByte(unsigned char Data)
 119          {
 120   1              unsigned char i;
 121   1              for(i=0;i<8;i++) {
 122   2                      HT1621DATA = (bit)(Data & 0x01);
 123   2                      HT1621Clk();
 124   2                      Data >>= 1;
 125   2              }
 126   1      }
 127          //向HT1621送一个6位的址,先送高位(A5--A0)。
 128          void SendAddress(unsigned char LcdRamAddress)
 129          {
 130   1              unsigned char i;
 131   1              LcdRamAddress <<= 2;         
 132   1              for(i=0;i<6;i++) {
 133   2                      HT1621DATA = (bit)(LcdRamAddress & 0x80);
 134   2                      HT1621Clk();
 135   2                      LcdRamAddress <<= 1;
 136   2              }
 137   1      
 138   1      }
 139          //向HT1621送数据头:101.
 140          void SendDataHead(void)
 141          {
 142   1              HT1621DATA = 1; 
 143   1              HT1621Clk();
 144   1              HT1621DATA = 0;
 145   1              HT1621Clk();    
 146   1              HT1621DATA = 1;
 147   1              HT1621Clk();
 148   1      }
 149          //向HT1621送命令头:100.
 150          void SendCmdHead(void)
 151          {
 152   1              HT1621DATA = 1;
 153   1              HT1621Clk();            //送了1
 154   1              HT1621DATA = 0;         //0
 155   1              HT1621Clk();            //送了0
 156   1              HT1621DATA = 0; 
 157   1              HT1621Clk();            //又送了0
 158   1      
 159   1      }
 160          /*
 161          //向HT1621送命令头:100.
 162          void SendCmdHead(void)
 163          {
 164                  HT1621DATA = 1;         //1
 165                  HT1621SCL  = 1;
 166                  HT1621CS_2 = 1;
 167                  _nop_();
 168                  _nop_();
 169                  _nop_();
 170                  HT1621CS_2 = 0;
 171                  _nop_();
 172                  _nop_();
 173                  _nop_();
 174                  HT1621Clk();            //送了1
C51 COMPILER V8.06   HT1621                                                                02/13/2009 09:29:11 PAGE 4   

 175                  HT1621DATA = 0;         //0
 176                  HT1621Clk();            //送了0
 177                  HT1621DATA = 0; 
 178                  HT1621Clk();            //又送了0
 179          
 180          }
 181          */
 182          void EnableFirstHT1621(void)
 183          {
 184   1              HT1621DATA = 1;         //1
 185   1              HT1621SCL  = 1;
 186   1              HT1621CS1 = 1;
 187   1              _nop_();
 188   1              _nop_();
 189   1              _nop_();
 190   1              HT1621CS1 = 0;
 191   1              _nop_();
 192   1              _nop_();
 193   1              _nop_();
 194   1              _nop_();
 195   1              _nop_();
 196   1              _nop_();
 197   1      }
 198          
 199          void EnableSecondHT1621(void)
 200          {
 201   1              HT1621DATA = 1;
 202   1              HT1621SCL  = 1;
 203   1              HT1621CS2 = 1;
 204   1              _nop_();
 205   1              _nop_();
 206   1              _nop_();
 207   1              HT1621CS2 = 0;
 208   1              _nop_();
 209   1              _nop_();
 210   1              _nop_();
 211   1              _nop_();
 212   1              _nop_();
 213   1              _nop_();
 214   1      } 
 215          void InitialHT1621(void)
 216          {
 217   1              EnableFirstHT1621();
 218   1              EnableSecondHT1621();
 219   1              SendCmdHead();
 220   1              SendCommand(0x01);      // 0000 0001b   ;Start the system clock
 221   1              SendCommand(0x18);      // 0x18=内部rc振荡,0x14=ext clc 32k
 222   1              //HT1621Clk();          // Send The "X"
 223   1              SendCommand(0x03);      // 0000 0011b   ;Allows Light the LCD 
 224   1              //HT1621Clk();          // Send The "X"
 225   1              SendCommand(0x29);      // 0010 1001b   ;1/3bias 4 commons option
 226   1              //HT1621Clk();          // Send The "X"
 227   1              //禁止HT1621
 228   1              HT1621CS1 = 1;
 229   1              SendCommand(0x0d);      // clr timer
 230   1      //      SendCommand(0x07);      // clr timer
 231   1              SendCommand(0x06);      // timer en
 232   1              SendCommand(0x88);      // irq en 
 233   1              SendCommand(0xa3);      // irq en 
 234   1              Display_Exe(1, 1, 15);//显示电话机座
 235   1              HT1621CS2 = 1;
 236   1      } 
C51 COMPILER V8.06   HT1621                                                                02/13/2009 09:29:11 PAGE 5   

 237          
 238          //清屏
 239          void ClearDisplay(void)
 240          {
 241   1              unsigned char i;
 242   1              EnableFirstHT1621();
 243   1              EnableSecondHT1621();
 244   1              SendDataHead();//数据头命令
 245   1              SendAddress(0);//起始地址
 246   1              for(i=0;i<16;i++)
 247   1              {
 248   2                      //m_DisplayDriveBuf[0][i] = 0;
 249   2                      m_DisplayDriveBuf[0][i] = 0;
 250   2                      if(i != 5)
 251   2                      {
 252   3                              m_DisplayDriveBuf[1][i] = 0;
 253   3                      }
 254   2                      else
 255   2                      {
 256   3                              m_DisplayDriveBuf[1][i] = (m_DisplayDriveBuf[1][i] & 0x08);
 257   3                      }
 258   2                      SendOneByte(0);//清掉1621两个ram数据
 259   2              }
 260   1              HT1621CS1 = 1;
 261   1              HT1621CS2 = 1;
 262   1      }
 263          
 264          /******************************************************************************
 265          //函数说明
 266          //location: 字符位置, icID = 0  0-11第一行,12-19第二行,20-31第三行
 267          //character:字符取值和代表意义见字模表
 268          *******************************************************************************/
 269          void DisplayChar(unsigned char location,unsigned char character)
 270          {
 271   1      //      unsigned char xdata *DisplayBuffer;
 272   1      //      unsigned char code  *FontAddress;
 273   1              unsigned char Font;
 274   1              unsigned char icID;
 275   1              if(location > 31)       return;
 276   1              //确定字符位置
 277   1              if (location<=11) icID=0;       //显示的第一行字符(location=0-11)为第一芯片(icID=0)的0-11
 278   1              else if ((location>=12)  && (location<=15)){
 279   2                      icID=1;                                 //显示的第二行前4个字符(location=12-15)为第二芯片(icID=1)的0-3
 280   2                      location=location-12;
 281   2              }
 282   1              else if ((location>=16)  && (location<=19)){

⌨️ 快捷键说明

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