PC2004 LCM Driver

Publisher:Blissful444Latest update time:2016-08-08 Source: eefocusKeywords:PC2004 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
#include

/*********************************************************** 
File name: Driver for PC2004 series character LCM module of POWERTIPAuthor 
: FreeVersion
: v01Description 
: Address 0x80~0xa7,0xc0~0xe7;
                First line: 0x80~0x96; Second line: 0xc0~0xd6;
   Third line: 0x97~0xa7; Fourth line: 0xd7~0xe7;
Modification record: None 
***********************************************************/
typedef unsigned char Uchar;
typedef unsigned int Uint;

#define LCDCmdPort P0
#define LCDDataPort P0
sbit LCD_RS  = P2^7;
sbit LCD_E   = P2^6;

/* LCD busy detection function*/  
void LCDBusy(void)
{
  Uchar i;               
  for(i=0;i<80;i++)      
  {}                     
}
/* LCD control command function*/ 
void LCDCmd(char c)
{     
  LCDBusy();              
  LCDCmdPort=c;           
  LCD_RS=0;               
  LCD_E=1;                
  LCD_E=0;                
}
/* LCD data input function*/ 
void LCDData(char d)
{     
  LCDBusy();            
  LCDDataPort=d;        
  LCD_RS=1;             
  LCD_E=1;              
  LCD_E=0;              

/* LCD initialization function*/ 
void LCDInit(void)
{
  LCD_E=1;                              
  LCD_RS=1;                             
  LCDCmd(0x38); //function set          
  LCDCmd(0x0c); //display on/off        
  LCDCmd(0x06); //set entry mode        
  LCDCmd(0x02); //return home           
  LCDCmd(0x01); //clear display         
}
/* Display string function, addr displays the starting address of the string*/
void LCDStr(Uchar addr,Uchar *s)    
{     
  idata int d=0;                                
  LCDCmd(addr); //Display address//      
  while (s[d]!=0x00)                            
  LCDData(s[d++]); // char of LCM //           
}
/*p is the first address of the string or array, len is the number of strings, the array should be a two-dimensional array of ≤4*20 or a one-dimensional array of ≤80*/
void LCDSz(Uchar *p,Uchar len)
{
  Uchar i;                                     
  LCDCmd(0x80); //Display address//         
  while(*p!=0x00)                              
  {for(i=0;i     {LCDData(*p++);}                         
   break;                                      
  }                                            
}

Keywords:PC2004 Reference address:PC2004 LCM Driver

Previous article:AT89C4051+TLC7225I three-phase AC signal source
Next article:AT89C2051+AD7545 sine signal generator

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号