模块LM12864FBC-1 这块液晶的引脚为 1--CS1 2--CS2 3--GND 4--VCC 5--V0 6--D/I(RS) 7--R/W 8--EN 9~16--D0~D7 17--BLA 18--BLK 19--NC 20--Vout
奇怪没有RST复位引脚,说明书上面Vout和VCC接一个25K的电位器分压给V0调对比度即可,对比度是可以调整了 想做一个驱动显示几个汉字 程序如下: #include <hidef.h> /* common defines and macros */ #include <6812a64.h> /* derivative information */ #include "my_vectors.h" #include "main_asm.h" /* interface to my assembly module */
///////////接口相关宏定义/////////////////// #define CS1 PTT_PTT0 //块1 左边 #define CS2 PTT_PTT1 //块2 右边 #define D_I PTT_PTT2 //A0为1时是数据,0时为指令数据 #define R_W PTT_PTT3 //为1时是读,为0时是写 #define E PTT_PTT4 //允许装载数据 #define DATA PORTB //数据 //////////////////////////////////////
#pragma CODE_SEG __NEAR_SEG NON_BANKED /* Interrupt section for this module. Placement will be in NON_BANKED area. */ //interrupt void RTI_ISR(void) { /* simple RTI interrupt service routine */ /* clear RTIF bit */ // static i=0; //闪烁小灯,每隔400ms闪烁一次 // i++; // if(i>100){PTT_PTT5=~PTT_PTT5;PORTA_BIT0=PTT_PTT5;PORTA_BIT2=~PORTA_BIT0;i=0; } // CRG**_RTIF=1; //CRG** = 0x80; //}
#pragma CODE_SEG DEFAULT static void RTIInit(void) { /* setup of the RTI interrupt frequency */ /* adjusted to get 1 millisecond (1.024 ms) with 16 MHz oscillator */ /*--------锁相环初始化-------*/ CLKSEL=0x00; //disable pll; PLLCTL=0xe1; //CLOCK MONITOR=ON,PLL=ON,AUTO SELECT,是默认设置 SYNR=14;REFDV=2; //bus clock =20M PLLCTL=0x60; //自动锁定 asm NOP;asm NOP;asm NOP; while(!CRG**_LOCK); CLKSEL=0x80; //pll start RTICTL = 0x1F; /* set RTI prescaler */ // CRGINT_RTIE=1; //允许RTI中断 asm CLI; //CRGINT = 0x80; /* enable RTI interrupts */ DDRT_DDRT5=1; DDRA_BIT0=1; DDRA_BIT2=1; RDRT=0xff; RDRIV=0x93; DDRB=0xff; ////PORTB为输出引脚 DDRT=0xff; ////PORT T 为输出引脚 }
/*忙判别*/ void lcd_busy(void) {DDRB_BIT7=0; D_I=0;R_W=1; while(1){E=1;_asm nop; if(!PORTB_BIT7)break;} E=0;DDRB_BIT7=1; } /*设置xy*/ void set_xy(unsigned char x,unsigned char y) { if (x>=64) {CS1=0;CS2=1;} else {CS2=0;CS1=1;} lcd_busy(); E=1;D_I=0;R_W=0;PORTB=0x40|x;E=0; lcd_busy(); E=1;D_I=0;R_W=0;PORTB=0xb8|y;E=0; } void lw(unsigned char x,unsigned char y,unsigned char dd) { set_xy(x,y); lcd_busy();E=1;D_I=1;R_W=0;PORTB=dd;E=0; } /*显示初始化*/ void lcd_init(void) { unsigned char x,y; /*开显示*/ E=1;D_I=0;R_W=0;PORTB=0x3f;E=0; for (y=0;y<8;y++) { for (x=0;x<128;x++) lw(x,y,0x00); //清空屏幕 } }
void Lcd_off(void){ E=1;D_I=0;R_W=0;PORTB=0x3e;E=0; }
/*汉字点阵的提取:采用软件"字模提取软件",读法:先读前8行,黑点处为1,依次读完这16列,然后读后8行,依次再读完16列。*/ unsigned char hz[]={ /*汉字:一 */ //0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,0x80,0x00, //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00, 0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x03,0x00,0x01,0x00,0x00,0x00,
/*汉字:倪*/ //0x80,0x40,0xf0,0x0f,0x02,0x00,0xfe,0x92,0x92,0x81,0x91,0x92,0x92,0xfe,0x00,0x00, //0x00,0x00,0x7f,0x00,0x40,0x20,0x11,0x0c,0x03,0x00,0x3f,0x40,0x40,0x41,0x78,0x00,
0x01,0x00,0x02,0x00,0x0F,0xFE,0xF0,0x00,0x40,0x02,0x00,0x04,0x7F,0x88,0x49,0x30, 0x49,0xC0,0x81,0x00,0x89,0xFC,0x49,0x02,0x49,0x02,0x7F,0x82,0x00,0x1E,0x00,0x00, /*汉字:水*/ //0x00,0x10,0x10,0x10,0x90,0x70,0x00,0xff,0x20,0x60,0x90,0x08,0x04,0x00,0x00,0x00, //0x10,0x10,0x08,0x06,0x01,0x40,0x80,0x7f,0x00,0x00,0x01,0x06,0x0c,0x18,0x08,0x00,
0x00,0x08,0x08,0x08,0x08,0x10,0x08,0x60,0x09,0x80,0x0E,0x02,0x00,0x01,0xFF,0xFE, 0x04,0x00,0x06,0x00,0x09,0x80,0x10,0x60,0x20,0x30,0x00,0x18,0x00,0x10,0x00,0x00,
/*汉字:好*/ //0x10,0x10,0xf0,0x1f,0x10,0xf0,0x80,0x82,0x82,0x82,0xf2,0x8a,0x86,0x82,0x80,0x00, //0x80,0x43,0x22,0x14,0x0c,0x73,0x20,0x00,0x40,0x80,0x7f,0x00,0x00,0x00,0x00,0x00,
0x08,0x01,0x08,0xC2,0x0F,0x44,0xF8,0x28,0x08,0x30,0x0F,0xCE,0x01,0x04,0x41,0x00, 0x41,0x02,0x41,0x01,0x4F,0xFE,0x51,0x00,0x61,0x00,0x41,0x00,0x01,0x00,0x00,0x00,
/*汉字:人*/ //0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x3f,0xc2,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0x00,0x40,0x20,0x10,0x0c,0x03,0x00,0x00,0x01,0x06,0x0c,0x18,0x30,0x60,0x20,0x00
0x00,0x00,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x30,0x00,0xC0,0x03,0x00,0xFC,0x00, 0x43,0x80,0x00,0x60,0x00,0x30,0x00,0x18,0x00,0x0C,0x00,0x06,0x00,0x04,0x00,0x00
};
/*显示汉字,注意本函数参数 x 为屏幕横着的坐标(范围从0~128),y为屏幕纵向的坐标(范围为0~8),n为要显示数足hz[]中的第几个字符 注意:由于本例显示的是16*16点阵,所以第一个字符占据横着16个点,纵向16个点,也就是纵向2页,所以下一个字符应该从第2页开始,再下一个从第4页开始 如主程序中调用的dh(0,0,0); dh(0,2,1); dh(0,4,2); */ void dh(unsigned char x,unsigned char y,unsigned char n) { unsigned char i,dd; for (i=0;i<16;i++) { dd=hz[i+n*32]; lw(x+i,y,dd); dd=hz[i+n*32+16]; lw(x+i,y+1,dd); } }
void main(void) { RTIInit(); /* put your own code here */ EnableInterrupts; asm_main(); lcd_init(); dh(0,0,0); //在横向0,纵向0页处显示汉字 "一" dh(0,2,1); //在横向0,纵向第2页处显示汉字 "倪" dh(0,4,2); //在横向0,纵向第四页处显示汉字 "水" dh(18,0,3); //在横向第18点,纵向0页处显示汉字 "好" dh(18,2,4); //Lcd_off(); for(;;); /* wait forever */ } 抱歉这个程序其本是网上得到的,在这谢谢网友们的无私贡献!! 各位有谁做过这块液晶的驱动的,能否给个程序参考以下 QQ:89590025 MSN:canon_me@hotmail.com |