智能车制作

标题: 关于5110液晶只有黑屏,没有字符显示(调了对比度就是不显示字符) [打印本页]

作者: 系髓    时间: 2014-6-25 20:50
标题: 关于5110液晶只有黑屏,没有字符显示(调了对比度就是不显示字符)
/***********************************************************
函数名称:LCD_write_byte
函数功能:模拟SPI接口时序写数据/命令LCD
入口参数:data    :写入的数据;
          command :写数据/命令选择;
出口参数:无
备 注:
***********************************************************/
void LCD_write_byte(unsigned char data,unsigned char command)
  {
    unsigned char i;
    LCD_CE=0;                                          //5110片选有效,允许输入数据
    if(command==0)                  //写命令
    {
     LCD_DC=0;                                    //数据/命令切换引脚
    }
    else
    {
     LCD_DC=1;                  //写数据
    }
          for(i=0;i<8;i++)                //传送8bit数据
                {
                 SCLK=0;
                 if(data&0x80)      //&为位与运算1101&1111=1101
                {
                 SDIN=1;
                }
                 else
                {  
                 SDIN=0;
                }
                 SCLK=1;
                 data=data<<1;  
                }
    LCD_CE=1;                                        //禁止5110
  }



/***********************************************************
函数名称:LCD_init
函数功能:5110初始化
入口参数:无
出口参数:无
备 注:
***********************************************************/
void LCD_init(void)
  {
   LCD_RST=0;     //产生一个让LCD复位的低电平脉冲
   delay_1us();
   LCD_RST=1;
   LCD_CE=0;      //关闭LCD    *****(CE为片选端,0为输入有效)*****
   delay_1us();
   LCD_CE=1;      //使能LCD
   delay_1us();


    LCD_write_byte(0x21,0);        // 使用扩展命令设置LCD模式
    LCD_write_byte(0xc5,0);        // 设置液晶偏置电压
    LCD_write_byte(0x06,0);        // 温度校正
    LCD_write_byte(0x13,0);        // 1:48(偏置系统设置)
    LCD_write_byte(0x20,0);        // 使用基本命令,V=0,水平寻址
    LCD_write_byte(0x0c,0);        // 设定显示配置,普通模式
    LCD_CE=1;      // 关闭LCD
  }



/***********************************************************
函数名称:LCD_set_XY
函数功能:设置LCD坐标函数
入口参数:X       :0-83
          Y       :0-5
出口参数:无
备 注:
***********************************************************/
void LCD_set_XY(unsigned char X, unsigned char Y)
  {                                
    LCD_write_byte(0x40|Y,0);                  // column
    LCD_write_byte(0x80|X,0);     // row
  }  


/***********************************************************
函数名称:LCD_write_char
函数功能:字符显示程序
***********************************************************/  
void LCD_write_char(unsigned char c)
{
    int line;
    c=c-32;
    for(line=0;line<6;line++)
    {  
     LCD_write_byte(font6x8[c][line],1);  
    }
}



/***********************************************************
函数名称:LCD_write_english_string
函数功能:打印字符串
***********************************************************/  
void LCD_write_english_string(unsigned char X,unsigned char Y,unsigned char *s)
  {
    LCD_set_XY(X,Y);
    while(*s)
    {
     LCD_write_char(*s++);
    }
  }


/***********************************************************
函数名称:LCD_clear
函数功能?LCD清屏函数
***********************************************************/
void LCD_clear(void)
{
char t;  
char k;  
LCD_set_XY(0,0);  
for(t=0;t<6;t++)   //因液晶可自动向前推进,所以写一次地址即可
{     
  for(k=0;k<84;k++)  
  {     
   LCD_write_byte(0x00,1);      
  }   
}
}


作者: 下一站。等你    时间: 2014-6-25 20:54
设置偏置电压试试
作者: 夜下的沉思    时间: 2014-6-26 11:28
供电电压高了吧?
作者: 系髓    时间: 2014-6-26 12:12
5V供电,液晶上写着3~5V,应该没问题吧

作者: 幼儿园的LELE    时间: 2014-6-28 21:02
我们用的3.3 没有问题
作者: Need-freedom    时间: 2014-6-29 04:55
我们的液晶能正常显示 但会突然清屏(非程序设定) 不知道为啥  求指点啊

作者: 系髓    时间: 2014-6-29 22:42
Need-freedom 发表于 2014-6-29 04:55
我们的液晶能正常显示 但会突然清屏(非程序设定) 不知道为啥  求指点啊

我都只有黑屏,还想请教你呢

作者: ▲_important゜    时间: 2014-6-30 13:12
系髓 发表于 2014-6-29 22:42
我都只有黑屏,还想请教你呢

偏置电压





欢迎光临 智能车制作 (http://111.231.132.190/) Powered by Discuz! X3.2