• 回复
  • 收藏
  • 点赞
  • 分享
  • 发新帖

关于PIC VS 12864LCD 显示问题

请教各位老师,我由于对12864LCD显示屏不太了解,最近搞了个12864显示程序,为什么LCD里面只显示"中国南京市雨花台"为什么"区"自无显示呢,应该在第二行显示才对.请各位老师指教,谢谢!
原程序如下:
#define  RS   RD2    //DI    
#define  RW   RD3    
#define  E    RD4    
#define  CS1  RD7    
#define  CS2  RD6    
#define  RST  RD5
#define  LED3 RC4
#define  LED4 RC5
#define  LED2 RD0
#define  LED1 RD1  
unsigned   char  PAGEADD;  //存放页地址寄存器    
unsigned   char  PAGENUM;  //存放总页数寄存器    
unsigned   char  CLMSUM;   //存放总列数寄存器    
unsigned   char  CLMADD;   //存放列地址寄存器    
unsigned   char  WRITE;    //存放显示数据寄存器    
unsigned   char  row;      //存放显示起始行寄存器    
unsigned   char  i,k;      //通用寄存器    
const  char  table[]=  
{  
/*--  文字:  中  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0xFC,0x08,0x08,0x08,0x08,0xFF,0x08,0x08,0x08,0x08,0xFC,0x08,0x00,0x00,
0x00,0x00,0x07,0x02,0x02,0x02,0x02,0xFF,0x02,0x02,0x02,0x02,0x07,0x00,0x00,0x00

/*--  文字:  国  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0xFE,0x02,0x0A,0x8A,0x8A,0x8A,0xFA,0x8A,0x8A,0x8A,0x0A,0x02,0xFE,0x00,0x00,
0x00,0xFF,0x40,0x48,0x48,0x48,0x48,0x4F,0x48,0x49,0x4E,0x48,0x40,0xFF,0x00,0x00

/*--  文字:  江  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x10,0x60,0x01,0xC6,0x30,0x00,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x00,0x00,
0x04,0x04,0x7E,0x01,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x00

/*--  文字:  苏  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x04,0x04,0x44,0x44,0x44,0x5F,0x44,0xF4,0x44,0x5F,0x44,0xC4,0x04,0x04,0x04,0x00,
0x00,0x40,0x4C,0x27,0x10,0x0C,0x07,0x01,0x20,0x40,0x40,0x3F,0x00,0x02,0x0C,0x00

/*--  文字:  省  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x10,0x90,0x88,0x86,0xC0,0xC0,0xBF,0xA0,0x90,0x90,0x8A,0x84,0x18,0x00,0x00,
0x01,0x01,0x00,0x00,0xFF,0x4A,0x4A,0x4A,0x4A,0x4A,0x4A,0x4A,0xFF,0x00,0x00,0x00

/*--  文字:  南  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x04,0x04,0xE4,0x24,0x24,0x64,0xB4,0x2F,0x24,0xA4,0x64,0x24,0x24,0xE6,0x04,0x00,
0x00,0x00,0x7F,0x04,0x05,0x05,0x05,0x7F,0x05,0x05,0x05,0x25,0x44,0x3F,0x00,0x00

/*--  文字:  京  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x04,0x04,0xE4,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0xE4,0x06,0x04,0x00,0x00,
0x00,0x20,0x10,0x19,0x0D,0x41,0x81,0x7F,0x01,0x01,0x05,0x0D,0x38,0x10,0x00,0x00

/*--  文字:  市  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x04,0x04,0x04,0xE4,0x24,0x24,0x25,0xFE,0x24,0x24,0x24,0x24,0xE4,0x04,0x04,0x00,
0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0xFF,0x00,0x00,0x10,0x20,0x1F,0x00,0x00,0x00

/*--  文字:  雨  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x02,0x02,0xF2,0x32,0x52,0x92,0x12,0xFE,0x32,0x52,0x92,0x12,0xF2,0x02,0x02,0x00,
0x00,0x00,0xFF,0x01,0x02,0x04,0x00,0x7F,0x01,0x02,0x44,0x80,0x7F,0x00,0x00,0x00

/*--  文字:  花  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x04,0x04,0x04,0x84,0xF4,0x2F,0x04,0x04,0xE4,0x0F,0x04,0xC4,0x84,0x04,0x04,0x00,
0x00,0x02,0x01,0x00,0xFF,0x00,0x08,0x04,0x3F,0x42,0x41,0x40,0x40,0x78,0x20,0x00

/*--  文字:  台  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0x00,0x40,0x60,0x50,0x48,0x44,0x63,0x22,0x20,0x20,0x28,0x70,0x20,0x00,0x00,
0x00,0x00,0x00,0x7F,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,0x00,0x00

/*--  文字:  区  --*/
/*--  宋体12;  此字体下对应的点阵为:宽x高=16x16   --*/
0x00,0xFE,0x02,0x02,0x12,0x22,0x22,0x42,0x82,0x62,0x1E,0x0A,0x02,0x02,0x00,0x00,
0x00,0x3F,0x20,0x30,0x28,0x24,0x22,0x21,0x20,0x21,0x26,0x3C,0x28,0x20,0x00,0x00


};  
//****************************************************************    
//延时程序(x*0.5ms)(1ms*93)    
void    delay(unsigned int x)  
{  
    unsigned int j;  
    for(j=x*50;--j;)  
        continue;  
}  
//****************************************************************    
//系统各口的输入输出状态初始化子程序    
void        INITIAL()  
{  
    //ADCON1=0X87;            //设置PORTA口和PORTE口为数字I/O口    
    TRISC=0XCF;    
    TRISD=0X00;
    TRISB=0X00;  
    //TRISE=0X00;      
    PORTD=0X00;    
    PORTC=0X00;             //设置液晶的4个控制脚为输出    
    RST=0;        //Reset.    
    NOP();    
    delay(2);    
    RST=1;    
    NOP();
    delay(2);
    LED3=0;
    LED4=0;
    LED1=0;
    LED2=0;  
    delay(2);      
}  
  
//*******************************************************************    
//*******************E1边的处理部分**********************************    
//*******************************************************************    
//*****************写命令程序*******************************    
void send_com1(unsigned char command )    
{    
  delay(1);// check_busy1();    
  CS1=1;       //左边    
  CS2=0;          
  RS=0;    
  RW=0;    
  PORTB=command;    
  E =1;    
  NOP();    
  NOP();    
  E =0;    
}      
//***********对液晶显示器写数据子程序************************    
void send_data1(unsigned char data )    
{    
    delay(1); // check_busy1();  //查询液晶是否为空闲    
    CS1=1;              //左边    
    CS2=0;    
    RS=1;    
    RW=0;                  
    PORTB=data;     //需要写入的数据放入D口    
    E =1;       //E1=0,写入数据    
    NOP();    
    E =0;  
}  
//************E1边清屏子程序***************************    
void    CLEAR1()  
{  
     PAGEADD=0xB8;    //设置页地址代码0页    
     for(PAGENUM=0X08;PAGENUM>0;PAGENUM--) //8页    
     {  
       send_com1(PAGEADD);    
       CLMADD=0x00;            //设置起始列    
       for(CLMSUM=0X40;CLMSUM>0;CLMSUM--) //64列    
        {  
         send_data1(0x00);      //写入00H以清屏    
        }  
        PAGEADD++;      //页号增1    
    }  
}      
  
//************E1边初始化**********************************    
void    lcd1()  
{  
     send_com1(0XC0);   //起始行0    
     send_com1(0X3F);   //开显示    
     CLEAR1();      //清屏    
}      
//*******************************************************************    
//*******************E2边的处理部分**********************************    
//*******************************************************************    
//*****************写命令程序*******************************    
void send_com2(unsigned char command )    
{    
  delay(1);  //check_busy2();    
  CS1=0;       //右边    
  CS2=1;          
  RS=0;    
  RW=0;    
  PORTB=command;    
  E =1;    
  NOP();    
  NOP();    
  E =0;    
}      
//***********对液晶显示器写数据子程序************************    
void send_data2(unsigned char data )    
{    
    delay(1); //check_busy2();      
    CS1=0;         //右边    
    CS2=1;    
    RS=1;    
    RW=0;                  
    PORTB=data;     //需要写入的数据放入D口    
    E =1;       //E1=0,写入数据    
    NOP();    
    E =0;  
}  
//************E2边清屏子程序************************    
void    CLEAR2()  
{  
    PAGEADD=0xB8;    //设置页地址代码0页    
    for(PAGENUM=0X08;PAGENUM>0;PAGENUM--) //8页    
     {  
       send_com2(PAGEADD);        
       CLMADD=0x40;                      //设置起始列0    
       for(CLMSUM=0X40;CLMSUM>0;CLMSUM--) //64列    
         {  
          send_data2(0x00);         //写入00H以清屏    
         }  
       PAGEADD++;           //页号增1    
     }  
}      
//************E2边初始化**********************************    
void    lcd2()  
{  
     send_com2(0XC0);   //起始行0    
     send_com2(0X3F);   //开显示    
     CLEAR2();      //清屏            
}  
//******************************************************************    
//******************************************************************    
//LCD的E1边显示函数,调用一次该函数,则在相应的位置显示相应的字    
void    dis1()  
{  
    send_com1(CLMADD);      //设置起始列    
    send_com1(PAGEADD);  
    i=i*32;                 //i变成数组指示指针    
    for(k=0;k<=16;k++)      
      {  
        WRITE=table[i+k];   //查得需要显示的字节    
        send_data1(WRITE);  //在WRITE1子程序里面,列地址加1    
        CLMADD++;  
      }  
    CLMADD=CLMADD-16;//恢复列地址    
    send_com1(CLMADD);      //设置起始列    
    PAGEADD=PAGEADD+1;//页地址加1    
    send_com1(PAGEADD);  
    for(;k<32;k++)  
      {  
        WRITE=table[i+k];   //查得需要显示的字节    
        send_data1(WRITE);  //列地址加1    
      }    
}  
//*******************************************************************    
//LCD的E2边显示函数,调用一次该函数,则在相应的位置显示相应的字    
void    dis2()  
{  
     send_com2(CLMADD);      //设置起始列    
     send_com2(PAGEADD);  
     i=i*32;                 //i变成数组指示指针    
     for(k=0;k<16;k++)      
      {  
        WRITE=table[i+k];    //查得需要显示的字节    
        send_data2(WRITE);   //列地址加1    
        CLMADD++;  
      }  
     CLMADD=CLMADD-16;      //恢复列地址    
     send_com2(CLMADD);     //设置起始列    
     PAGEADD=PAGEADD+1;     //页地址加1    
     send_com2(PAGEADD);  
     for(;k<32;k++)      
       {  
         WRITE=table[i+k];    //查得需要显示的字节    
         send_data2(WRITE);   //在WRITE1子程序里面,列地址已经加1    
       }        
}  
//*************************************************************************    
//*****************************主程序**************************************    
//*************************************************************************    
main()  
{  
    INITIAL();              //系统初始化    
    lcd1();                 //E1边初始化    
    lcd2();
    delay(20);
    delay(10);                    //E2边初始化    
//******以下显示不同的字符*************************************************      
    PAGEADD=0XB8;       //显示起始页为第0页    
    CLMADD=0X40;        //起始列为第0列    
    i=0;                //中//  
    dis1();             //调用显示函数    
  
    PAGEADD=0XB8;       //显示起始页为第0页    
    CLMADD=0X50;        //起始列为第16列    
    i=1;                //国    
    dis1();             //调用显示函数1  
  
    PAGEADD=0XB8;       //显示起始页为第0页    
    CLMADD=0X60;        //起始列为第32列    
    i=2;                //江    
    dis1();             //调用显示函数1    
  
    PAGEADD=0XB8;       //显示起始页为第0页    
    CLMADD=0X70;        //起始列为第0列    
    i=3;                //苏    
    dis1();             //调用显示函数2    
      
    PAGEADD=0XB8;       //显示起始页为第0页    
    CLMADD=0X40;        //起始列为第64列    
    i=4;                //省  
    dis2();             //调用E2边显示函数    
  
    PAGEADD=0XB8;       //显示起始页为第0页    
    CLMADD=0X50;        //起始列为第16列    
    i=5;                //南      
    dis2();             //调用显示函数2    
  
    PAGEADD=0XB8;       //显示起始页为第0页    
    CLMADD=0X60;        //起始列为第32列    
    i=6;                //京      
    dis2();             //调用显示函数2

    PAGEADD=0XB8;       //显示起始页为第0页    
    CLMADD=0X70;        //起始列为第32列    
    i=7;                //市      
    dis2();             //调用显示函数2

    PAGEADD=0XBA;       //显示起始页为第0页    
    CLMADD=0X40;        //起始列为第32列    
    i=8;                //雨    
    dis1();             //调用显示函数2

    PAGEADD=0XBA;       //显示起始页为第0页    
    CLMADD=0X50;        //起始列为第32列    
    i=9;                //花    
    dis1();             //调用显示函数2
  
    PAGEADD=0XBA;       //显示起始页为第0页    
    CLMADD=0X60;        //起始列为第32列    
    i=10;                //台    
    dis1();             //调用显示函数2
  
    PAGEADD=0XBA;       //显示起始页为第0页    
    CLMADD=0X70;        //起始列为第32列    
    i=11;                //公    
    dis1();             //调用显示函数2

    PAGEADD=0XBA;       //显示起始页为第0页    
    CLMADD=0X40;        //起始列为第32列    
    i=12;                //区    
    dis2();             //调用显示函数2    
     delay(2);
     while(1)  
         {
          
    
    LED1=1;
    delay(20000);
    delay(20000);
    delay(20000);
    delay(200000000000);
    LED1=0;
            }        
}
全部回复(1)
正序查看
倒序查看
leasor
LV.3
2
2009-03-21 08:44
你都不换行,又怎么会在第二行显示呢?
0
回复