打印

怎样让128*64的液晶屏显示8*16的字母和数字啊?

[复制链接]
5029|10
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
liang.t.x|  楼主 | 2007-6-6 14:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
请教各位:
    我在做一个实验,用的是128*64不带字库的液晶屏,要怎么样才能显示8*16的字母和数字呢?汉字显示的是16*16的字,以下是显示8*8字母的程序:

;西文字符写入子程序CW_PR(12864)
;  占用内部资源:O_XL,O_YL,DAIMA,COUNT1,A,B,DPTR
;  内部调用子程序:PR1,PR2,PR4,PR5
;  连接字库: CHTAB
;  程序调用入口: CW_PR
;   程序输入变量:  O_XL,O_YL,DAIMA
        CW_PR:  MOV     DPTR,#CHTAB    ; 确定字符字模块首地址                     
                MOV     A,DAIMA        ; 取代码
                MOV     B,#08H        ; 字模块宽度为8个字节
                MUL     AB        ; 代码x8
                ADD     A,DPL        ; 字符字模块首地址
                  MOV     DPL,A        ; = 字模库首地址 + 代码x8
                MOV     A,B
                ADDC    A,DPH
                MOV     DPH,A    
                MOV     DAIMA,#00H       ; 借用为间址寄存器
                MOV     A,O_YL          ; 读页地址寄存器
                JB      ACC.7,CW_1    ; 判字符体
                MOV     COUNT1,#06H    ; 6*8点阵
                LJMP    CW_2
        CW_1:   MOV     COUNT1,#08H    ; 8*8点阵
        CW_2:   ANL     A,#07H          ; 取页地址值
                ORL     A,#0B8H        ; "或"页地址指令代码
                MOV     COM,A        ; 写页地址指针
                LCALL   PR1
                LCALL   PR4
                MOV     A,O_XL            ; 读列地址寄存器
                CLR     C
                SUBB    A,#40H          ; 列地址-64
                JC      CW_3            ; 〈0为左屏显示区域
                MOV     O_XL,A          ; ≥0为右屏显示区域
                MOV     A,O_YL
                SETB    ACC.5           ; 设置区域标志位.
                MOV     O_YL,A          ; "00"为左,"10"为右
        CW_3:   MOV     COM,O_XL        ; 设置列地址值
                ORL     COM,#40H        ; "或"列地址指令标志位
                MOV     A,O_YL          ; 判区域标志以确定设置哪个控制器
                ANL     A,#30H
        CW_31:  CJNE    A,#20H,CW_32    ; "10"为右区
                LCALL   PR4
                LJMP    CW_4
        CW_32:  LCALL   PR1             ; "00"为左区
        CW_4:   MOV     A,DAIMA          ; 取间址寄存器值
                MOVC    A,@A+DPTR    ; 取字符字模数据    
        JNB    REVERSE,CW_40
        CPL    A
        CW_40: MOV     DAT1,A        ; 写数据
                MOV     A,O_YL          ; 判区域标志
                ANL     A,#30H
        CW_41:  CJNE    A,#20H,CW_42    ; "10"为右区
                LCALL   PR5
                LJMP    CW_5
        CW_42:  LCALL   PR2             ; "00"为左区
        CW_5:   INC     DAIMA            ; 间址加1
                INC     O_XL        ; 列地址加1
                MOV     A,O_XL            ; 判列地址是否超出区域范围
                CJNE    A,#40H,CW_6
        CW_6:   JC      CW_9            ; 未超出则继续
                MOV     O_XL,#00H       ;
                MOV     A,O_YL          ; 超出则判在何区域
                JB      ACC.5,CW_91     ; 在右区域则退出
        CW_61:  SETB    ACC.5           ; 在左区则转右区
                MOV     O_YL,A
                MOV     COM,#40H        ; 设置右区列地址为"0"
                LCALL   PR4
        CW_9:   DJNZ    COUNT1,CW_4     ; 循环
        CW_91:  RET

相关帖子

沙发
李冬发| | 2007-6-6 14:41 | 只看该作者

做8*16的字模,其它一样的,就是2个8*8

使用特权

评论回复
板凳
liang.t.x|  楼主 | 2007-6-6 14:52 | 只看该作者

以上的程序不知道要如何去该呢

使用特权

评论回复
地板
sfofyyy| | 2007-6-6 14:54 | 只看该作者

呵呵,刚做好一个

  刚做好一个12864串行显示汉字和图形,用24c32做字库,不过感觉屏幕有点暗,速度也不够快,显示一个屏幕的汉字能看出快慢来.
  楼主还是仔细看看datasheet,应该有例程的.如果真的不会,乐意帮忙.

使用特权

评论回复
5
keer_zu| | 2007-6-6 15:07 | 只看该作者

方法很重要

只要你能在你的128*64指定位置显示一个字节,其它的都好办了, 劝liang.t.x 使用c语言。

使用特权

评论回复
6
liang.t.x|  楼主 | 2007-6-6 15:19 | 只看该作者

小弟初学,请4楼的朋友帮帮忙好吗?

使用特权

评论回复
7
sfofyyy| | 2007-6-6 17:05 | 只看该作者

是的

keer_zu 说的是关键,一般来说,初始化的部分datasheet上应该有的,你就依葫芦画瓢就行了,主要是看明白时序,弄清写数据和写命令的区别.不过我用的这款不分左右区的.我也是第一次用.sfofyyy@hotmail.com.上班时间在线.

使用特权

评论回复
8
liang.t.x|  楼主 | 2007-6-7 14:54 | 只看该作者

没人指点了吗

使用特权

评论回复
9
dtsaint| | 2007-6-7 17:49 | 只看该作者

哪个东西很简单的啦

慢慢看看例程和DATASHEET

使用特权

评论回复
10
hqgboy| | 2007-6-7 20:27 | 只看该作者

。。。

/******************************************************************************************/
//
/******************************************************************************************/
typedef struct typCHAR_12    
{
    unsigned char Index[1];
    unsigned char Msk[16];
};
/******************************************************************************************/
//
/******************************************************************************************/
struct typCHAR_12 code CHAR_12[]={        //16*8 字符
"1",0x00,0x00,0x20,0x20,0xF8,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x1F,0x10,0x10,0x00,
"2",0x00,0x30,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x18,0x14,0x12,0x11,0x10,0x18,0x00,
"3",0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x0C,0x10,0x10,0x10,0x11,0x0E,0x00,
"4",0x00,0x80,0x40,0x20,0xF8,0x00,0x00,0x00,0x00,0x03,0x02,0x12,0x1F,0x12,0x12,0x00,
"5",0x00,0xF8,0x88,0x48,0x48,0x48,0x88,0x00,0x00,0x0C,0x10,0x10,0x10,0x10,0x0F,0x00,
"6",0x00,0xE0,0x10,0x88,0x88,0x98,0x00,0x00,0x00,0x0F,0x11,0x10,0x10,0x10,0x0F,0x00,
"7",0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,
"8",0x00,0x70,0x88,0x88,0x88,0x88,0x70,0x00,0x00,0x0E,0x11,0x10,0x10,0x11,0x0E,0x00,
"9",0x00,0xF0,0x08,0x08,0x08,0x90,0xE0,0x00,0x00,0x00,0x19,0x11,0x11,0x08,0x07,0x00,
"0",0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x07,0x08,0x10,0x10,0x08,0x07,0x00,
".",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,
"a",0x00,0x20,0x90,0x50,0x50,0xE0,0x00,0x00,0x00,0x03,0x04,0x04,0x04,0x07,0x04,0x00,
"b",0x02,0xFE,0x20,0x10,0x10,0x10,0xE0,0x00,0x00,0x07,0x04,0x04,0x04,0x04,0x03,0x00,
"c",0x00,0xC0,0x20,0x10,0x10,0x10,0x20,0x00,0x00,0x01,0x02,0x04,0x04,0x04,0x02,0x00,
"d",0x00,0xE0,0x10,0x10,0x10,0x12,0xFE,0x00,0x00,0x03,0x04,0x04,0x04,0x02,0x07,0x04,
"e",0x00,0xE0,0x50,0x50,0x50,0x50,0x60,0x00,0x00,0x03,0x04,0x04,0x04,0x04,0x02,0x00,
"f",0x00,0x10,0x10,0xFC,0x12,0x12,0x06,0x00,0x00,0x04,0x04,0x07,0x04,0x04,0x00,0x00,
"g",0x00,0xB0,0x48,0x48,0x48,0x38,0x08,0x00,0x00,0x06,0x09,0x09,0x09,0x09,0x06,0x00,
"h",0x02,0xFE,0x20,0x10,0x10,0x10,0xE0,0x00,0x04,0x07,0x04,0x00,0x00,0x04,0x07,0x04,
"i",0x00,0x10,0x16,0xF6,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x07,0x04,0x04,0x00,0x00,
"k",0x02,0xFE,0x80,0x40,0xB0,0x10,0x10,0x00,0x04,0x07,0x04,0x00,0x05,0x06,0x04,0x00,
"l",0x00,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x07,0x04,0x04,0x00,0x00,
"m",0x10,0xF0,0x10,0xF0,0x10,0xE0,0x00,0x00,0x04,0x07,0x00,0x07,0x00,0x07,0x04,0x00,
"n",0x10,0xF0,0x20,0x10,0x10,0x10,0xE0,0x00,0x04,0x07,0x04,0x00,0x00,0x04,0x07,0x04,
"o",0x00,0xC0,0x20,0x10,0x10,0x20,0xC0,0x00,0x00,0x01,0x02,0x04,0x04,0x02,0x01,0x00,
"p",0x08,0xF8,0x10,0x08,0x08,0x08,0xF0,0x00,0x08,0x0F,0x0A,0x02,0x02,0x02,0x01,0x00,
"q",0x00,0xF0,0x08,0x08,0x08,0x08,0xF8,0x00,0x00,0x01,0x02,0x02,0x02,0x09,0x0F,0x08,
"r",0x10,0x10,0xF0,0x20,0x10,0x10,0x30,0x00,0x04,0x04,0x07,0x04,0x04,0x00,0x00,0x00,
"s",0x00,0x60,0x90,0x90,0x90,0x30,0x00,0x00,0x00,0x06,0x04,0x04,0x04,0x03,0x00,0x00,
"t",0x00,0x10,0x10,0xFC,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,0x00,
"u",0x10,0xF0,0x00,0x00,0x00,0x10,0xF0,0x00,0x00,0x03,0x04,0x04,0x04,0x02,0x07,0x04,
"v",0x10,0x30,0xD0,0x00,0x00,0xD0,0x30,0x10,0x00,0x00,0x01,0x06,0x01,0x00,0x00,0x00,
"w",0x10,0xF0,0x00,0xF0,0x00,0xF0,0x10,0x00,0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00,
"x",0x00,0x10,0x30,0xC0,0xD0,0x30,0x10,0x00,0x00,0x04,0x06,0x05,0x01,0x06,0x04,0x00,
"y",0x08,0x18,0xE8,0x00,0x80,0x68,0x18,0x08,0x08,0x08,0x08,0x07,0x01,0x00,0x00,0x00,
"z",0x00,0x30,0x10,0x90,0x50,0x30,0x10,0x00,0x00,0x04,0x06,0x05,0x04,0x04,0x06,0x00,
"_",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
"/",0x00,0x00,0x00,0xE0,0x18,0x07,0x00,0x00,0x00,0x0C,0x03,0x00,0x00,0x00,0x00,0x00,
":",0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00,
" ",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
">",0x00,0x00,0x40,0x40,0x80,0x80,0x00,0x00,0x01,0x01,0x05,0x05,0x03,0x03,0x01,0x01,
"<",0x00,0xFC,0x07,0x07,0x04,0xF8,0x00,0x00,0x10,0x9F,0xF0,0x90,0xF0,0x9F,0x10,0x00,
"O",0xF8,0x04,0x02,0x02,0x02,0x04,0xF8,0x00,0x01,0x02,0x04,0x04,0x04,0x02,0x01,0x00,
"N",0x00,0x02,0xFE,0x0E,0x70,0x82,0xFE,0x02,0x00,0x04,0x07,0x04,0x00,0x03,0x07,0x00,
"D",0x00,0x02,0xFE,0x02,0x02,0x02,0x04,0xF8,0x00,0x04,0x07,0x04,0x04,0x04,0x02,0x01,
"S",0x00,0x78,0x04,0x04,0x04,0xF8,0x00,0x00,0x7F,0xFF,0xEF,0xC7,0xEF,0xFF,0x7F,0x00,
"C",0x00,0xF0,0x08,0x08,0x08,0x08,0x38,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x10,0x00,
"%",0xE0,0x50,0xE0,0x90,0x68,0x14,0x0A,0x00,0x00,0x31,0x0C,0x03,0x0E,0x11,0x0E,0x00,
"+",0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x0F,0x01,0x01,0x01,
"-",0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
";",0x00,0x00,0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x08,0x04,0x02,0x01,0x00
};
/******************************************************************************************/
//

/*=====================OLED部分开始=====================*/
/**/
/******************************************************************************************/
//     OLED清屏模块
/******************************************************************************************/
void clear_prog()
{
        unsigned char i,j;
    for(i=0;i<8;i++)
    {
        wr_command(0xb0+i);     //页面地址设置
        wr_command(0x0);   //列地址设置
        wr_command(0x10);  //列地址设置
        for(  j=0; j<128; j++)
        {                 //RAM清"0"
            wr_data(0x0);
            gui_disp_buf[j] =0;
        }
    }
}
/******************************************************************************************/



/******************************************************************************************/
//    显示字符
/******************************************************************************************/
void dprintf_CHAR12 (unsigned char line,column,unsigned char str[20],color)
{
    unsigned char i=0,c1,ulen;
    ulen = (unsigned char)sprintf(dispbuff,"%s",str);
    
    while(i<ulen)
    {
        c1 = dispbuff;
        for(jj=0;jj<sizeof(CHAR_12)/sizeof(CHAR_12[0]);jj++)//寻找字库
        {
            if(c1 == CHAR_12[jj].Index[0])
                break;
        }
        display_prog(line,column,3,color);
        column++;

         i++;
    }
}

/******************************************************************************************/
//
/******************************************************************************************/
void wr_command(unsigned char data com) //写命令(0-128 行)子程序
{
    EA = 0;
    D_C = 0;              // D_C=0,数据送至指令寄存器
      CS1_LOW;       //Chip select
    _nop_();                
    _nop_();  
    P0 = com;
    _nop_();                                                                 //用此NOP代替读状态
    _nop_();                                                                 //用此NOP代替读状态
              
    r_w = 0;
    _nop_();
    _nop_();
    r_w = 1;
    _nop_();
    _nop_();
    CS1_HIGH;       //Chip select
    _nop_();
    _nop_();
    EA=1;
}
/******************************************************************************************/
//
/******************************************************************************************/
void wr_data(unsigned char data dat) //写数据(65-128 行)子程序
{
    EA=0;
    D_C = 1;       //D_C=1,数据送至RAM
    CS1_LOW;       //Chip select
    _nop_();
    _nop_();
    P0 = dat;
    _nop_();                                                               //用此NOP代替读状态
    _nop_();                                                               //用此NOP代替读状态

    r_w = 0;
    _nop_();
    _nop_();
    r_w = 1;
    _nop_();
    _nop_();
    CS1_HIGH;       //Chip select
    _nop_();
    _nop_();
    EA=1;
}

/******************************************************************************************/
//
/******************************************************************************************/
// void oled_display(unsigned char picture[])
//{
//    unsigned char j;
//    for(page=0;page<8;page++)
//    {
//        wr_command(176+page); //set page address

//        wr_command(0x00);    //set low address

//        wr_command(0x10);    //set higher address

//        for(j=0;j<128;j++)
//        {
//             wr_data(picture[j+page*128]);
//        }       
//   }
//}
/*
void show_picture(unsigned char picture[])
{
    uchar j;
    for(page=0;page<8;page++)
    {

        wr_command(0xb0+page); //set page address

        wr_command(0x00);    //set low address

        wr_command(0x10);    //set higher address

        for(j=0;j<16;j++)//picture is 58*64
        {
             wr_data(picture[j+page*16]);
        }       
    }
}
*/
/******************************************************************************************
//     OLED初始化函数
******************************************************************************************/
void init_oled() //初始化
{
        unsigned char i;
    en = 1;
    r_w = 1;
    RST_LOW ;
    for(i=0;i<100;i++);          
    RST_HIGH ;
    for(i=0;i<100;i++);
    
    wr_command(0xAE); //Display off
    wr_command(0xAD); //Internal DC-DC off
    wr_command(0x8A); // Second byte
    wr_command(0xA8); //MUX Ratio
    wr_command(0x3F); //64 duty
    wr_command(0xD3); //Display offset
    wr_command(0x00); //Second byte
    wr_command(0x40); //Start line
    wr_command(0xA0); //Segment remap        //a0
    wr_command(0xC8); //COM remap
    wr_command(0xA6); //Set normal/inverse display (0xA6:Normal display)
    wr_command(0xA4); //Set entire display on/off (0xA4:Normal display)
    wr_command(0x81); //Contrast setting
    wr_command(0x5c); //Second byte 5c
    wr_command(0xD5); //Frame rate
    wr_command(0x60); // 85 Hz
    wr_command(0xD8); //Mode setting
    wr_command(0x00); //Mono mode
    wr_command(0xD9); //Set Pre-charge period
    wr_command(0x84); // Second byte
    wr_command(0xAF); //Display on
}

/******************************************************************************************
**
**
**
******************************************************************************************/

使用特权

评论回复
11
LIANG.T.X| | 2007-6-8 11:10 | 只看该作者

我的程序初始化是这样的,有问题吗

 ;  初始化子程序INT
;  内部调用子程序:PR1,PR4
;  程序调用入口:INT
;  程序调用变量:无
    LCDINT:     MOV     COM,#0C0H      ; 设置显示起始行为第一行
                LCALL   PR1
                LCALL   PR4
                MOV     COM,#3FH       ; 开显示设置
                LCALL   PR1
                LCALL   PR4
                RET

; 间接驱动驱动子程序由6个子程序组成
;  占用内部资源:COM,DAT1,A
;  占用系统资源:CSA,CSB,RS,RW,E1,DATBUS
;  程序输入变量:COM 或 DAT1
; 1. 左区驱动子程序
; 1.1 写指令代码子程序(左)
        PR1:    CLR     CSA            ; 片选设置为"01"
                SETB    CSB            ;
                CLR     RS             ; RS=0
                SETB    RW             ; R/W=1
        PR11:   MOV     DATBUS,#0FFH   ; DATBUS口置"1"
                SETB    E1             ; E=1
                MOV     A,DATBUS       ; 读状态字
                CLR     E1             ; E=0
                JB      ACC.7,PR11     ; 判"忙"标志为"0"否, 否再读
                CLR     RW             ; R/W=0
                MOV     DATBUS,COM     ; 写指令代码
                SETB    E1             ; E=1
                CLR     E1             ; E=0
                RET
; 1.2 写显示数据子程序(左)
        PR2:    CLR     CSA            ; 片选设置为"01"
                SETB    CSB            ;
                CLR     RS             ; RS=0
                SETB    RW             ; R/W=1
        PR21:   MOV     DATBUS,#0FFH   ; DATBUS口置"1"
                SETB    E1             ; E=1
                MOV     A,DATBUS       ; 读状态字
                CLR     E1             ; E=0
                JB      ACC.7,PR21     ; 判"忙"标志为"0"否, 否再读
                SETB    RS             ; RS=1
                CLR     RW             ; R/W=0
                MOV     DATBUS,DAT1    ; 写数据
                SETB    E1             ; E=1
                CLR     E1             ; E=0
                RET
; 1.3 读显示数据子程序(左)
        PR3:    CLR     CSA            ; 片选设置为"01"
                SETB    CSB            ;
                CLR     RS             ; RS=0
                SETB    RW             ; R/W=1
        PR31:   MOV     DATBUS,#0FFH   ; DATBUS口置"1"
                SETB    E1             ; E=1
                MOV     A,DATBUS       ; 读状态字
                CLR     E1             ; E=0
                JB      ACC.7,PR31     ; 判"忙"标志为"0"否, 否再读
                SETB    RS             ; RS=1
                MOV     DATBUS,#0FFH   ; DATBUS口置"0"
                SETB    E1             ; E=1
                MOV     DAT1,DATBUS    ; 读数据
                CLR     E1             ; E=0
                RET
; 2. 右区驱动子程序
; 2.1 写指令代码子程序(右)
        PR4:    SETB    CSA            ; 片选设置为"10"
                CLR     CSB            ;
                CLR     RS             ; RS=0
                SETB    RW             ; R/W=1
        PR41:   MOV     DATBUS,#0FFH   ; DATBUS口置"1"
                SETB    E1             ; E=1
                MOV     A,DATBUS       ; 读状态字
                CLR     E1             ; E=0
                JB      ACC.7,PR41     ; 判"忙"标志为"0"否, 否再读
                CLR     RW             ; R/W=0
                MOV     DATBUS,COM     ; 写指令代码
                SETB    E1             ; E=1
                CLR     E1             ; E=0
                RET
; 2.2 写显示数据子程序(右)
        PR5:    SETB    CSA            ; 片选设置为"10"
                CLR     CSB            ;
                CLR     RS             ; RS=0
                SETB    RW             ; R/W=1
        PR51:   MOV     DATBUS,#0FFH   ; DATBUS口置"1"
                SETB    E1             ; E=1
                MOV     A,DATBUS       ; 读状态字
                CLR     E1             ; E=0
                JB      ACC.7,PR51     ; 判"忙"标志为"0"否, 否再读
                SETB    RS             ; RS=1
                CLR     RW             ; R/W=0
                MOV     DATBUS,DAT1    ; 写数据
                SETB    E1             ; E=1
                CLR     E1             ; E=0
                RET
; 2.3 读显示数据子程序(右)
        PR6:    SETB    CSA            ; 片选设置为"10"
                CLR     CSB            ;
                CLR     RS             ; RS=0
                SETB    RW             ; R/W=1
        PR61:   MOV     DATBUS,#0FFH   ; DATBUS口置"1"
                SETB    E1             ; E=1
                MOV     A,DATBUS       ; 读状态字
                CLR     E1             ; E=0
                JB      ACC.7,PR61     ; 判"忙"标志为"0"否, 否再读
                SETB    RS             ; RS=1
                MOV     DATBUS,#0FFH   ; DATBUS口置"0"
                SETB    E1             ; E=1
                MOV     DAT1,DATBUS    ; 读数据
                CLR     E1             ; E=0
                RET

使用特权

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

本版积分规则

21

主题

54

帖子

0

粉丝