打印

救命了!!!

[复制链接]
1225|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
colinluan|  楼主 | 2008-9-26 21:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
有谁用过LCD控制芯片S6B0724没,写个驱动,液晶一点反应都没有,调了好几天了,不知道错在哪里。高手们帮帮忙看看,单片机用的是PIC16F873,4M晶振,用的是8080的时序。

void LCD_WriteCmd(int8 cmd)
{
    output_low(PIN_B2);  //A0=0    
    output_high(PIN_B4); //R=1
    //*(0x07)=cmd;
    output_c(cmd);
    #asm
    NOP
    NOP
    NOP
    #endasm
    output_low(PIN_B3); //WR=0
    output_high(PIN_B3);  //WR=1
}


void LCD_WriteDat(int8 dat)
{
    output_high(PIN_B2);  //A0=1    
    output_high(PIN_B4);  //R=1
    //*(0x07)=dat;
    output_c(dat);
    #asm
    NOP
    NOP
    NOP
    #endasm
    output_low(PIN_B3); //WR=0
    output_high(PIN_B3);  //WR=1
}
int8 LCD_ReadStatus()
{
    int8 dat;
    set_tris_c(0xff);
    output_low(PIN_B2);  //A0=0
    output_high(PIN_B3);  //WR=1
    output_low(PIN_B4); //R=0
    #asm
    NOP
    NOP
    NOP
    #endasm
    dat=input_c();
    output_high(PIN_B4);  //R=1
    set_tris_c(0x00);
    return dat;
}

void LCD_Init()
{
    
    output_low(PIN_B6);  //8080
    output_low(PIN_B5);  //CS1=0;
    
    //液晶复位
    output_low(PIN_B1);
    delay_ms(10);
    output_high(PIN_B1);
    delay_us(1);
    
    //ADC select seg0-seg131
    LCD_WriteCmd(0xa0);
    //SHL select com0-com64
    LCD_WriteCmd(0xc8); 
    //LCD Bias select
    LCD_WriteCmd(0xa2);
    //Voltage Converter ON //Voltage Regulator ON //Voltage Follower ON
    LCD_WriteCmd(0x2c);
    delay_ms(2);
    LCD_WriteCmd(0x2a);
    delay_ms(2);
    LCD_WriteCmd(0x29);
    delay_ms(2);
    
    LCD_WriteCmd(0x81);
    
    LCD_WriteCmd(0x27);
    LCD_WriteCmd(0x40);
    LCD_WriteCmd(0xaf);
}

void main()
{
    int8 i=0;
    
    set_tris_a(0xff);
    set_tris_b(0x01);
    set_tris_c(0x00);
    port_b_pullups(0xff);
    LCD_Init();

    i=LCD_ReadStatus();
    putc(i);  //串口输出状态

         LCD_WriteCmd(0xb0);  //setpage
    LCD_WriteCmd(0x00);
    LCD_WriteCmd(0x10);
    for(i=0;i<=50;i++)
    {
        LCD_WriteDat(0xff);
    }
    for(i=51;i<=100;i++)
    {
        LCD_WriteDat(0x00);
    }

    LCD_WriteCmd(0xb1);  //setpage
    LCD_WriteCmd(0x10);
    LCD_WriteCmd(0x0a);
    for(i=0;i<=50;i++)
    {
        LCD_WriteDat(0xff);
    }
    for(i=51;i<=100;i++)
    {
        LCD_WriteDat(0x00);
    }
      while(1);


    

}

相关下载

相关帖子

沙发
0x小丑| | 2008-9-26 21:47 | 只看该作者

寄存器的初始化可能有问题

LCD_WriteCmd(0x81);
指令后面应该跟有一个指令的数据的,这个数据会影响显示的灰度

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

43

主题

83

帖子

0

粉丝