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

📄 lcd.lst

📁 hi this for LCD interface
💻 LST
字号:
C51 COMPILER V8.12   LCD                                                                   12/02/2008 19:19:07 PAGE 1   


C51 COMPILER V8.12, COMPILATION OF MODULE LCD
OBJECT MODULE PLACED IN LCD.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Nokia3310Driver\LCD.c BROWSE DEBUG OBJECTEXTEND PRINT(.\LCD.lst) OBJECT(LCD
                    -.obj)

line level    source

   1          /*****************************************************
   2          
   3                  Plug n Play Library for Nokia 3310 LCD
   4          
   5                  Author:  Ajay Bhargav
   6                          Email :  contact@rickeyworld.info
   7                          WWW   :  www.8051projects.net
   8          
   9                          File  :  LCD.C
  10                          Info  :  easy to use library function
  11          
  12          *****************************************************/
  13          
  14          #include "lcd.h"
  15          
  16          /* Lookup Table for Nokia LCD */
  17          const unsigned char code FontLookup [][5] =
  18          {
  19              { 0x00, 0x00, 0x00, 0x00, 0x00 },  // sp
  20              { 0x00, 0x00, 0x2f, 0x00, 0x00 },   // !
  21              { 0x00, 0x07, 0x00, 0x07, 0x00 },   // "
  22              { 0x14, 0x7f, 0x14, 0x7f, 0x14 },   // #
  23              { 0x24, 0x2a, 0x7f, 0x2a, 0x12 },   // $
  24              { 0xc4, 0xc8, 0x10, 0x26, 0x46 },   // %
  25              { 0x36, 0x49, 0x55, 0x22, 0x50 },   // &
  26              { 0x00, 0x05, 0x03, 0x00, 0x00 },   // '
  27              { 0x00, 0x1c, 0x22, 0x41, 0x00 },   // (
  28              { 0x00, 0x41, 0x22, 0x1c, 0x00 },   // )
  29              { 0x14, 0x08, 0x3E, 0x08, 0x14 },   // *
  30              { 0x08, 0x08, 0x3E, 0x08, 0x08 },   // +
  31              { 0x00, 0x00, 0x50, 0x30, 0x00 },   // ,
  32              { 0x10, 0x10, 0x10, 0x10, 0x10 },   // -
  33              { 0x00, 0x60, 0x60, 0x00, 0x00 },   // .
  34              { 0x20, 0x10, 0x08, 0x04, 0x02 },   // /
  35              { 0x3E, 0x51, 0x49, 0x45, 0x3E },   // 0
  36              { 0x00, 0x42, 0x7F, 0x40, 0x00 },   // 1
  37              { 0x42, 0x61, 0x51, 0x49, 0x46 },   // 2
  38              { 0x21, 0x41, 0x45, 0x4B, 0x31 },   // 3
  39              { 0x18, 0x14, 0x12, 0x7F, 0x10 },   // 4
  40              { 0x27, 0x45, 0x45, 0x45, 0x39 },   // 5
  41              { 0x3C, 0x4A, 0x49, 0x49, 0x30 },   // 6
  42              { 0x01, 0x71, 0x09, 0x05, 0x03 },   // 7
  43              { 0x36, 0x49, 0x49, 0x49, 0x36 },   // 8
  44              { 0x06, 0x49, 0x49, 0x29, 0x1E },   // 9
  45              { 0x00, 0x36, 0x36, 0x00, 0x00 },   // :
  46              { 0x00, 0x56, 0x36, 0x00, 0x00 },   // ;
  47              { 0x08, 0x14, 0x22, 0x41, 0x00 },   // <
  48              { 0x14, 0x14, 0x14, 0x14, 0x14 },   // =
  49              { 0x00, 0x41, 0x22, 0x14, 0x08 },   // >
  50              { 0x02, 0x01, 0x51, 0x09, 0x06 },   // ?
  51              { 0x32, 0x49, 0x59, 0x51, 0x3E },   // @
  52              { 0x7E, 0x11, 0x11, 0x11, 0x7E },   // A
  53              { 0x7F, 0x49, 0x49, 0x49, 0x36 },   // B
  54              { 0x3E, 0x41, 0x41, 0x41, 0x22 },   // C
C51 COMPILER V8.12   LCD                                                                   12/02/2008 19:19:07 PAGE 2   

  55              { 0x7F, 0x41, 0x41, 0x22, 0x1C },   // D
  56              { 0x7F, 0x49, 0x49, 0x49, 0x41 },   // E
  57              { 0x7F, 0x09, 0x09, 0x09, 0x01 },   // F
  58              { 0x3E, 0x41, 0x49, 0x49, 0x7A },   // G
  59              { 0x7F, 0x08, 0x08, 0x08, 0x7F },   // H
  60              { 0x00, 0x41, 0x7F, 0x41, 0x00 },   // I
  61              { 0x20, 0x40, 0x41, 0x3F, 0x01 },   // J
  62              { 0x7F, 0x08, 0x14, 0x22, 0x41 },   // K
  63              { 0x7F, 0x40, 0x40, 0x40, 0x40 },   // L
  64              { 0x7F, 0x02, 0x0C, 0x02, 0x7F },   // M
  65              { 0x7F, 0x04, 0x08, 0x10, 0x7F },   // N
  66              { 0x3E, 0x41, 0x41, 0x41, 0x3E },   // O
  67              { 0x7F, 0x09, 0x09, 0x09, 0x06 },   // P
  68              { 0x3E, 0x41, 0x51, 0x21, 0x5E },   // Q
  69              { 0x7F, 0x09, 0x19, 0x29, 0x46 },   // R
  70              { 0x46, 0x49, 0x49, 0x49, 0x31 },   // S
  71              { 0x01, 0x01, 0x7F, 0x01, 0x01 },   // T
  72              { 0x3F, 0x40, 0x40, 0x40, 0x3F },   // U
  73              { 0x1F, 0x20, 0x40, 0x20, 0x1F },   // V
  74              { 0x3F, 0x40, 0x38, 0x40, 0x3F },   // W
  75              { 0x63, 0x14, 0x08, 0x14, 0x63 },   // X
  76              { 0x07, 0x08, 0x70, 0x08, 0x07 },   // Y
  77              { 0x61, 0x51, 0x49, 0x45, 0x43 },   // Z
  78              { 0x00, 0x7F, 0x41, 0x41, 0x00 },   // [
  79              { 0x55, 0x2A, 0x55, 0x2A, 0x55 },   // 55
  80              { 0x00, 0x41, 0x41, 0x7F, 0x00 },   // ]
  81              { 0x04, 0x02, 0x01, 0x02, 0x04 },   // ^
  82              { 0x40, 0x40, 0x40, 0x40, 0x40 },   // _
  83              { 0x00, 0x01, 0x02, 0x04, 0x00 },   // '
  84              { 0x20, 0x54, 0x54, 0x54, 0x78 },   // a
  85              { 0x7F, 0x48, 0x44, 0x44, 0x38 },   // b
  86              { 0x38, 0x44, 0x44, 0x44, 0x20 },   // c
  87              { 0x38, 0x44, 0x44, 0x48, 0x7F },   // d
  88              { 0x38, 0x54, 0x54, 0x54, 0x18 },   // e
  89              { 0x08, 0x7E, 0x09, 0x01, 0x02 },   // f
  90              { 0x0C, 0x52, 0x52, 0x52, 0x3E },   // g
  91              { 0x7F, 0x08, 0x04, 0x04, 0x78 },   // h
  92              { 0x00, 0x44, 0x7D, 0x40, 0x00 },   // i
  93              { 0x20, 0x40, 0x44, 0x3D, 0x00 },   // j
  94              { 0x7F, 0x10, 0x28, 0x44, 0x00 },   // k
  95              { 0x00, 0x41, 0x7F, 0x40, 0x00 },   // l
  96              { 0x7C, 0x04, 0x18, 0x04, 0x78 },   // m
  97              { 0x7C, 0x08, 0x04, 0x04, 0x78 },   // n
  98              { 0x38, 0x44, 0x44, 0x44, 0x38 },   // o
  99              { 0x7C, 0x14, 0x14, 0x14, 0x08 },   // p
 100              { 0x08, 0x14, 0x14, 0x18, 0x7C },   // q
 101              { 0x7C, 0x08, 0x04, 0x04, 0x08 },   // r
 102              { 0x48, 0x54, 0x54, 0x54, 0x20 },   // s
 103              { 0x04, 0x3F, 0x44, 0x40, 0x20 },   // t
 104              { 0x3C, 0x40, 0x40, 0x20, 0x7C },   // u
 105              { 0x1C, 0x20, 0x40, 0x20, 0x1C },   // v
 106              { 0x3C, 0x40, 0x30, 0x40, 0x3C },   // w
 107              { 0x44, 0x28, 0x10, 0x28, 0x44 },   // x
 108              { 0x0C, 0x50, 0x50, 0x50, 0x3C },   // y
 109              { 0x44, 0x64, 0x54, 0x4C, 0x44 }    // z
 110          };
 111          
 112          static void Delay ()
 113          {
 114   1              int i;
 115   1              for ( i = -32000; i < 32000; i++ );
 116   1              for ( i = -32000; i < 32000; i++ );
C51 COMPILER V8.12   LCD                                                                   12/02/2008 19:19:07 PAGE 3   

 117   1              for ( i = -32000; i < 32000; i++ );
 118   1              for ( i = -32000; i < 32000; i++ );
 119   1      }
 120          
 121          /* Send single byte on SPI Bus (software) */
 122          /* Input Arguments: x -> Byte to send     */
 123          
 124          void spisend(unsigned char x){
 125   1              unsigned char i;
 126   1              for(i=8;i>0;i--){
 127   2                      SCK = 0;
 128   2                      if((x&0x80)){
 129   3                              DAT = 1;
 130   3                      } else {
 131   3                              DAT = 0;
 132   3                      }
 133   2                      SCK = 1;
 134   2                      x <<= 1;
 135   2              }
 136   1      }
 137          
 138          /* Write Data Byte to Nokia LCD              */
 139          /* Input Arguments: x-> Data Byte to be sent */
 140          
 141          void wrdata(unsigned char x){
 142   1              DC = 1;
 143   1              CE = 0;
 144   1              spisend(x);
 145   1              CE = 1;
 146   1      }
 147          
 148          /* Write Command Byte to Nokia LCD               */
 149          /* Input Arguments: x -> Command Byte to be sent */
 150          void wrcmd(unsigned char x){
 151   1              DC = 0;
 152   1              CE = 0;
 153   1              spisend(x);
 154   1              CE = 1;
 155   1      }
 156          
 157          /* Brings ram pointer to X,Y pixel position            */
 158          /* Input Arguments: x-> X cordinate range from 0 to 83 */
 159          /* Input Arguments: y-> Y cordinate range from 0 to 5  */
 160          void pixelxy(unsigned char x, unsigned char y)
 161          {
 162   1              wrcmd(0x40|(y&0x07));   // Y axis
 163   1              wrcmd(0x80|(x&0x7f));   // X axis
 164   1      }
 165          
 166          /* Clears the screen */
 167          void clearram(void)
 168          {
 169   1              int ddram;
 170   1              pixelxy(0,0);                                                                           // Cursor Home.
 171   1              for (ddram=504;ddram>0;ddram--) {wrdata(0x00);}         // 6*84 = 504 DDRAM addresses.
 172   1      }
 173          
 174          /* Nokia3310 LCD Initialization */
 175          void initlcd(void)
 176          {
 177   1              RES = 1;        // Set _RES HIGH.
 178   1              CE = 1;         // Disable Chip.
C51 COMPILER V8.12   LCD                                                                   12/02/2008 19:19:07 PAGE 4   

 179   1              ES = 0;         // Reset the LCD.
 180   1              Delay();        // Wait 100ms.
 181   1              ES = 1;         // Awake LCD from RESET state.
 182   1      
 183   1              wrcmd(0x21);            // Activate Chip and H=1.
 184   1              wrcmd(0xC2);            // Set LCD Voltage to about 7V.
 185   1              wrcmd(0x13);            // Adjust voltage bias.
 186   1              wrcmd(0x20);            // Horizontal addressing and H=0.
 187   1              wrcmd(0x09);            // Activate all segments.
 188   1              clearram();                     // Erase all pixel on the DDRAM.
 189   1              wrcmd(0x08);            // Blank the Display.
 190   1              wrcmd(0x0C);            // Display Normal.
 191   1              pixelxy(0,0);           // Cursor Home.
 192   1      }
 193          
 194          /* Bring cursor to Line and character specified                     */
 195          /* Input Arguments: row    -> Line number range from 1 to 6         */
 196          /* Input Arguments: Column -> character position range from 1 to 14 */
 197          /* You can have maximum of 6 lines of text on LCD and each line
 198             containing 14 characters. Address is auto increment              */
 199          
 200          void cursorxy(unsigned char row, unsigned char col){
 201   1              if((row>6) || (row<1) || (col<1) || (col>14))
 202   1                      return;
 203   1              pixelxy(((col-1)*6),(row-1));
 204   1      }
 205          
 206          /* Writes single character on LCD                   */
 207          /* Input Arguments: ch -> Character to be displayed */
 208          void putchar(unsigned char ch){
 209   1              unsigned char i, temp;
 210   1              if ( (ch < 0x20) || (ch > 0x7b) ){
 211   2                      ch = 92;
 212   2              }
 213   1              for(i=0;i<5;i++){
 214   2                      temp = FontLookup[ch - 32][i] << 1;
 215   2                      wrdata(temp);
 216   2              }
 217   1              wrdata(0x00);
 218   1      }
 219          
 220          /* Writes character string on LCD                            */
 221          /* Input Arguments: str -> Pointer to string to be displayed */
 222          void putstr (unsigned char *str){
 223   1              while(*str)
 224   1                      putchar(*str++);
 225   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    348    ----
   CONSTANT SIZE    =    455    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       3
   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 + -