本人去年在ZLG买了块2104ARM板子,现有块液晶DMF50081,控制器是SED1335,现在想把液晶给点亮。由于2104只有一个P0口,所以跟SED1335连线的是这样的:
2014 p0口 sed1335
p0.16 d0
p0.14 d1
p0.12 d2
p0.10 d3
p0.8 d4
p0.6 d5
p0.4 d6
p0.0 d7
p0.9 /wd
p0.7 /rd
p0.5 /cs
p0.3 a0
p0.1 /res
程序是这样写的:
#include "lcd.h"
#define A0 0x00000200 file://A0=1,command mode,A0=0,data mode.connect p0.9 #define RD 0x00002000 file://---/rd,connect p0.13 #define WD 0x00008000 file://---/wd,connect P0.15 #define CS 0x00000800 file://chip select,/cs.connect P0.11
#define RES 0x00000080 file://---/RES,P0.7 /********************************************************* * * when write command to the chip,the A0 must set be 1 and * the A0 must to be set 0 when write the var to the chip. * write COMMAND: A0 = 1, /CS = 0, /WR = 0 * write DATA : A0 = 0, /CS = 0, /RD = 0 *********************************************************/ #define D0 0x00010000 file://P0.16 #define D1 0x00004000 file://P0.14 #define D2 0x00001000 file://P0.12 #define D3 0x00000400 file://P0.10 #define D4 0x00000100 file://P0.8 #define D5 0x00000040 file://P0.6 #define D6 0x00000010 file://P0.4 #define D7 0x00000001 file://P0.0
uint32 Data[8]={D0,D1,D2,D3,D4,D5,D6,D7}; file://D? uint8 masks[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; file://mask for data
/************************************************************************ * 初始化,写入命令0x40,0x44,0x5A,0x5B,0x59 * 0x40:初始化设置,8个参数 * 0x44:显示域设置,10个参数 * 0x5A:点位移设置,1个参数 * 0x5B:显示合成设置,1个参数 * 0x59:显示状态设置,1个参数 ************************************************************************/ void init_lcd(void) { // PINSEL1 = OxFAAAAFFF & PINSEL1; /* uint8 sysvar[8] = {0x30,0x87,0x07,0x27,0x42,0xF0,0x28,0x00}; file://need confirm vars. file://0x30H = 00110000B,无边界、单屏系统、8*8点阵、80H-9FH范围的字符代码、内部字符发生器有效 file://0x87H = 10000111B,后4位字符宽度和字间距 file://0x07H = 00000111B,后4位字符高度和行间距 file://0x27H = 00100111B,有效的窗口长度:39个字符 file://0x42H = 01000010B,通常为70,此处设置为66 file://0xF0H = 11110000B,LCE行数:240行 file://0x28H = 00101000B,最后两个参数为参数4+1 file://0x00H = 00000000B, uint8 scrollvar[10] = {0x00,0x00,0xF0,0x80,0x25,0xF0,0x00,0x4B,0x80,0x70}; file://0x00 = 00000000B 第一个显示区的首地址以及占有显示屏上的点行数 file://0x00 = 00000000B file://0xF0 = 11110000B file://0x00 = 00000000B 第二个显示区的首地址以及占有显示屏上的点行数 file://0x40 = 01000000B file://0xF0 = 11110000B file://0x00 = 00000000B file://0x80 = 10000000B file://0x00 = 00000000B file://0x00 = 00000000B */ IOCLR = CS; IOCLR = RES; time_delay(10); IOSET = RES; wc(0x40); wd(0x30);wd(0x87);wd(0x07);wd(0x27);wd(0x2b);wd(0xF0);wd(0x28);wd(0x00); wc(0x44); wd(0x00);wd(0x00);wd(0xF0);wd(0x80);wd(0x25);wd(0xF0);wd(0x00);wd(0x4b);wd(0x80);wd(0x70); wc(0x5A); wd(0x00); wc(0x5B); wd(0x00); clear_lcd_ram(); wc(0x59); wd(0x54); // wc(0x5d);wd(0x07);wd(0x8f); }
/**************************************************************/ void wc(uint8 command) { IOCLR = CS; write(command); IOSET = A0; IOCLR = WD; // time_delay(50); IOSET = WD; IOSET = CS; } /**************************************************************/ void wd(uint8 data) { IOCLR =CS; write(data); IOCLR = A0; IOCLR = WD; // time_delay(50); IOSET = WD; IOSET = CS; } /*************************************************************/ void write(uint8 command) { uint8 i; uint8 tmp; for(i=0;i<8;i++) { tmp = masks & command; if(tmp == 0) IOCLR = Data; else IOSET = Data; } } /***************************************************************/ void clear_lcd_ram(void) { uint8 i,j; wc(0x4c); wc(0x46); wd(0x00); wd(0x00); wc(0x42); for(j=0;j<820;j++) { for(i=0;i<40;i++) { wd(0x00); } } }
但是运行的时候屏幕没有一点反映,不知道是什么原因,哪位搞过的朋友帮我看看,不甚感激。