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

📄 lcd_io.lst

📁 TI公司的增强型8位单片机upsd32xx系列芯片
💻 LST
📖 第 1 页 / 共 2 页
字号:
 204   4                                              LCD_reg.LCD_RAM_WR = (var & 0x0F)+'0';
 205   4                              }
 206   3                              else
 207   3                              if (*chr_ptr == 'x') {                  // display 1 byte hex 00-FF
 208   4                                      chr_ptr++;
 209   4      
 210   4                                      var = *var_ptr++;
 211   4                                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var>>4);
 212   4                                      LCD_reg.LCD_RAM_WR = htoa_hi(var);
 213   4                                      BusyCheck();
 214   4                              //LCD_reg.LCD_RAM_WR = Bin2Hex(var&0x0F);
 215   4                                      LCD_reg.LCD_RAM_WR = htoa_lo(var);
 216   4                              }
 217   3                              else
 218   3                              if (*chr_ptr == 'w') {                  // display 1 word hex 0000-FFFF
 219   4                                      chr_ptr++;
 220   4      
 221   4                                      var = *var_ptr++;
 222   4                                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var>>4);
 223   4                                      LCD_reg.LCD_RAM_WR = htoa_hi(var);
 224   4                              BusyCheck();
 225   4                              //LCD_reg.LCD_RAM_WR = Bin2Hex(var&0x0F);
 226   4                                      LCD_reg.LCD_RAM_WR = htoa_lo(var);
 227   4      
 228   4                              BusyCheck();
 229   4      
 230   4                                      var = *var_ptr++;
 231   4                                      //LCD_reg.LCD_RAM_WR = Bin2Hex(var>>4);
 232   4                                      LCD_reg.LCD_RAM_WR = htoa_hi(var);
 233   4                              BusyCheck();
 234   4                              //LCD_reg.LCD_RAM_WR = Bin2Hex(var&0x0F);
 235   4                                      LCD_reg.LCD_RAM_WR = htoa_lo(var);
 236   4                              }
 237   3                              else {
 238   4                                      LCD_reg.LCD_RAM_WR = *chr_ptr++;        //out character to LCD Diaplay RAM
 239   4                      }
 240   3                      }
 241   2                      else
C51 COMPILER V7.06   LCD_IO                                                                10/13/2004 10:12:17 PAGE 5   

 242   2                      {
 243   3                              LCD_reg.LCD_RAM_WR = *chr_ptr++;                //out character to LCD Diaplay RAM
 244   3                      }
 245   2              }
 246   1      }
 247          
 248          /*
 249          char Bin2Hex(char temp) {
 250          
 251                  if (temp <= 9) temp += '0'; else temp=(temp-10)+'A';
 252                  return (temp);
 253          }
 254          */
 255          
 256          //  These are the LCD functions.
 257          
 258          
 259          void lcd_clear(void)                    // clear all characters from display   
 260                  {
 261   1              BusyCheck();
 262   1              LCD_reg.LCD_CMD_WR = 0x01;
 263   1              Cursor_LCD = DD_ADDR;
 264   1              }
 265          /*
 266          void lcd_string_display(row,col,string)         
 267                                          // send string to LCD   
 268                                          // row = 0 is top row   
 269                                          // row = 1 is bottom    
 270                                          // col = 0 to 15            
 271                                          // length = string length   
 272                                          // string points to char array   
 273          unsigned char row;
 274          unsigned char col;
 275          unsigned char *string;
 276                  {
 277                  char k;
 278                  k = 0;
 279                  lcd_cursor_set(row,col);        // position cursor   
 280                  while (k < LCD_LINE_LENGTH+1 && *string)        // truncate string to 16 
 281                                                  // or end of string   
 282                          {
 283                          BusyCheck();
 284                          LCD_reg.LCD_RAM_WR = *string++; // send character   
 285                          k++;
 286                          }
 287                  }
 288          
 289          
 290          void lcd_char_display(row,col,ch)       // send single char to LCD   
 291                                                  // row = 0 is top row   
 292                                                  // row = 1 is bottom    
 293                                                  // col = 0 to 15            
 294          unsigned char row;
 295          unsigned char col;
 296          char ch;
 297                  {
 298                  lcd_cursor_set(row,col);        // position cursor   
 299                  BusyCheck();
 300                  LCD_reg.LCD_RAM_WR = ch;                        // send character   
 301                  }
 302          
 303                  
C51 COMPILER V7.06   LCD_IO                                                                10/13/2004 10:12:17 PAGE 6   

 304          
 305          void lcd_cursor_set(row,col)    // move cursor to desired position   
 306          unsigned char row;
 307          unsigned char col;
 308                  
 309                  {
 310                  BusyCheck();
 311                  switch(row)
 312                          {
 313                          case 0:
 314                                  LCD_reg.LCD_CMD_WR = (0x80 + col);
 315                                  break;
 316                                  
 317                          case 1:
 318                                  LCD_reg.LCD_CMD_WR = (0xC0 + col);
 319                                  break;
 320                          }
 321                  }
 322          
 323          */
 324          
 325          // this is a collection of conversion routines used in conjunction with the LCD display
 326          
 327          
 328          char htoa_lo(byte)       // converts low nibble of unsigned byte
 329                                                   // (0-F hex) to ascii   
 330          unsigned char byte;
 331                  {
 332   1              byte = byte & 0x0F;     // keep lower nibble only   
 333   1              if (byte <= 0x09)
 334   1                      return(byte + 0x30);
 335   1              else
 336   1                      return (byte + 0x37);
 337   1              }
 338          
 339          /*
 340          char lhtoa_lo(word)      // converts 2nd nibble of unsigned int
 341                                                   // (0-F hex) to ascii   
 342          unsigned int word;
 343                  {
 344                  word = word >> 8;
 345                  word = word & 0x000F;
 346                  if (word <= 0x0009)
 347                          return((char)word + 0x30);
 348                  else
 349                          return ((char)word + 0x37);
 350                  }
 351          */
 352          
 353          char htoa_hi(byte)       // converts hi nibble of unsigned byte
 354                                                   // (0-F hex) to ascii   
 355          unsigned char byte;
 356                  {
 357   1              byte = byte & 0xF0;     // keep upper nibble only   
 358   1              byte = byte >> 4;
 359   1              if (byte <= 0x09)
 360   1                      return(byte + 0x30);
 361   1              else
 362   1                      return (byte + 0x37);
 363   1              }
 364          
 365          /*
C51 COMPILER V7.06   LCD_IO                                                                10/13/2004 10:12:17 PAGE 7   

 366          char lhtoa_hi(word)      // converts 1st nibble of unsigned int
 367                                                   // (0-F hex) to ascii   
 368          unsigned int word;
 369                  {
 370                  word = word >> 12;
 371                  word = word & 0x000F;
 372                  if (word <= 0x0009)
 373                          return((char)word + 0x30);
 374                  else
 375                          return ((char)word + 0x37);
 376                  }
 377          
 378          */
 379          
 380          /*
 381          void copy_message(msg_ptr, destination)
 382          unsigned int msg_ptr;
 383          unsigned int destination;
 384                  {
 385                  xdata unsigned char i;
 386                  xdata unsigned char code * temp_add;
 387                   xdata unsigned char src_code;
 388                   xdata unsigned char xdata * dest_add;
 389             
 390                  
 391                  for (i=0; i<LCD_LINE_LENGTH; i++)
 392                          {
 393                          temp_add =  (unsigned char *) ( msg_ptr + i);     // get message byte
 394                          src_code =  *  temp_add;
 395                          dest_add = (unsigned char *) (destination + i);   // put message byte
 396                          * dest_add = src_code;
 397                          }       
 398                  }
 399          */


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    398    ----
   CONSTANT SIZE    =     57    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      1      25
   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 + -