1.起始
事情一开始是这样的,这一块是从自动寄存柜上拆下的屏幕。已经放置了两三年了,我想着给它用一下。具体的型号是M128128-1B1
使用的是少见的22pin脚位
然后很神奇,这玩意现在居然要卖几百块钱,这种几千都是虚标价格,实际价格应该在200-300之间,或者也没人知道具体多少。
但是以前的价格我们还是可以查到的,像是这一块Truly M128128只要十几块钱
这一个屏幕并不是太好驱动,最大问题是资料极其难找,我试着搜索Truly或者搜索128128都是不同的结果。
2.关于Truly
3.参考手册
truly-msp-g128128dyly-2w? 这个是其中一种g128128的,m128128的没找到
在线地址 ?truly-msp-g128128dyly-2w - 道客巴巴
4.参考程序
avr_truly_M240128driver??
在线地址
??avr_TRULY_M240128driver - 源码下载|嵌入式/单片机编程|单片机(51,AVR,MSP430等)|源代码 - 源码中国
TRULYM240128-1A1显示程序 - 百度文库
5.资料分析
看了一眼这个g128128的居然是1998年的资料 ?,也因此相关的内容非常难找
引脚的对应,但要注意这个是g128128,我看了一下,LEDA和LEDK是分别对应21,22
整个的原理图
驱动这一个屏幕,需要提供5V的电压,所以使用5V的MCU来控制是最好的,当然如果说单独提供电压给MCU,也可以用3.3V的来控制逻辑部分。另外有背光的驱动,需要提供高达380mA的大电流,背光的电压要控制在不超过4.6V典型为4.2V。
这也就是说背光的驱动上必须要加电阻至少加一个10欧姆(调试时候应该要加100欧姆)
但是同时我又找到一张m128128的资料,可以看出来用的液晶面板是有所不同的,模组的尺寸相差有一些,但是基本一致
这个是M128128
对比一下可以发现,是把东芝芯片换成了环氧树脂封装的某种芯片
另外还找到了M320240
这个是安装在这样的一个地方上,配的处理器还是ARM
6.突破口,唯一的程序
然后还好我更多的搜索了一下,终于在数码之家找到有一位网友可以点亮这一个屏幕的了,可以知道屏幕是使用KS0108,原帖地址 http://bbs.mydigit.cn/read.php?tid=2507002
最重要是给出来引脚图
和实际的进行一下对应,他上面写的加了一个数字行后非常容易引发误解。我通过K和A进行确认后确认这一引脚可能是对的。
?
从网友那边复制的代码有两个文件一个是ziku.h一个是main.c,他们使用的C51
ziku.h ?
unsigned char code ye[]=
{
0x10,0x61,0x86,0x60,0x84,0xE4,0x1C,0x84,0x45,0x3E,0xA4,0x24,0xE6,0x04,0x00,0x00,
0x02,0x3E,0x01,0x00,0x00,0x3F,0x21,0x20,0x11,0x0A,0x04,0x0B,0x10,0x20,0x00,0x00,
};
unsigned char code jin[]=
{
0x00,0x80,0x80,0x80,0xBE,0xAA,0x2A,0x2A,0xAA,0xAA,0xBF,0x82,0x80,0x00,0x00,0x00,
0x00,0x3F,0x14,0x14,0x14,0x3F,0x00,0x00,0x3F,0x14,0x14,0x14,0x3F,0x00,0x00,0x00,
};
unsigned char code xian[]=
{
0x00,0x00,0x00,0x7E,0x2A,0xAA,0x2A,0x2A,0xAA,0x2A,0x2A,0x7F,0x02,0x00,0x00,0x00,
0x20,0x21,0x22,0x2C,0x20,0x3F,0x20,0x20,0x3F,0x28,0x24,0x22,0x31,0x20,0x00,0x00,
};
unsigned char code shi[]=
{
0x00,0x20,0x22,0x22,0xA2,0x22,0x22,0xE2,0x22,0xA2,0x22,0x23,0x32,0x20,0x00,0x00,
0x00,0x08,0x04,0x02,0x01,0x10,0x20,0x1F,0x00,0x00,0x01,0x02,0x0C,0x00,0x00,0x00,
};
unsigned char code she[]=
{
0x20,0x20,0x21,0xE6,0x40,0x20,0x5E,0xC2,0x42,0x42,0x4F,0xD2,0x10,0x10,0x00,0x00,
0x00,0x00,0x00,0x0F,0x24,0x22,0x10,0x11,0x0A,0x04,0x0A,0x11,0x30,0x10,0x00,0x00,
};
unsigned char code ji[]=
{
0x20,0x21,0x22,0xE6,0x00,0x20,0x20,0x20,0x20,0xFF,0x20,0x20,0x30,0x20,0x00,0x00,
0x00,0x00,0x00,0x1F,0x08,0x04,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,
};
unsigned char code shang[]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x20,0x20,0x20,0x20,0x30,0x20,0x00,0x00,0x00,
0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0x10,0x10,0x10,0x10,0x10,0x18,0x10,0x00,0x00,
};
unsigned char code shan[]=
{
0x40,0x44,0x54,0x54,0xD5,0x56,0x54,0xFC,0x56,0xD5,0x54,0x56,0x44,0x40,0x00,0x00,
0x00,0x01,0x01,0x3D,0x25,0x25,0x25,0x25,0x25,0x25,0x3D,0x01,0x01,0x00,0x00,0x00,
};
unsigned char code ruo[]=
{
0x44,0x44,0x44,0x44,0x44,0xCF,0x74,0x44,0x44,0x4F,0x44,0x44,0x66,0x44,0x00,0x00,
0x08,0x08,0x04,0x02,0x3F,0x11,0x11,0x11,0x11,0x11,0x3F,0x00,0x00,0x00,0x00,0x00,
};
unsigned char code shui[]=
{
0x00,0x10,0x10,0x10,0xF0,0x00,0x00,0xFF,0xC0,0x20,0x10,0x08,0x00,0x00,0x00,0x00,
0x10,0x08,0x04,0x03,0x00,0x10,0x20,0x1F,0x00,0x01,0x02,0x04,0x08,0x08,0x00,0x00,
};
unsigned char code zhong[]=
{
//0x00,0xF8,0x08,0x08,0x08,0x08,0xFF,0x08,0x08,0x08,0x08,0xFC,0x08,0x00,0x00,0x00,
//0x00,0x01,0x01,0x01,0x01,0x01,0x3F,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,
// wo
0x20,0x24,0x24,0x24,0xFE,0x23,0x22,0x20,0x20,0xFF,0x20,0x22,0x2C,0xA0,0x20,0x00,
0x00,0x08,0x48,0x84,0x7F,0x02,0x41,0x40,0x20,0x13,0x0C,0x14,0x22,0x41,0xF8,0x00,
};
unsigned char code nan[]=
{
0x04,0x04,0xF4,0x14,0x14,0x54,0x94,0x1F,0x94,0x54,0x14,0x14,0xF6,0x04,0x00,0x00,
0x00,0x00,0x3F,0x00,0x05,0x05,0x05,0x1F,0x05,0x05,0x15,0x20,0x1F,0x00,0x00,0x00,
};
unsigned char code da[]=
{
0x10,0x10,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x10,0x10,0x18,0x10,0x00,0x00,
0x20,0x20,0x10,0x08,0x04,0x03,0x00,0x01,0x02,0x04,0x08,0x10,0x30,0x10,0x00,0x00,
};
unsigned char code xue[]=
{
0x20,0x18,0x08,0x29,0x2E,0x28,0x29,0xAE,0xA8,0x6C,0x2B,0x08,0x28,0x18,0x00,0x00,
0x02,0x02,0x02,0x02,0x02,0x12,0x22,0x1F,0x02,0x02,0x02,0x02,0x03,0x02,0x00,0x00,
};
main.c? 需要连接7+8=15条线
?
// é?é?è??? 2010 3 9 //
// ?D??′ó?§ //
// D??¢???§ó?1¤3ì?§?o //
#include "reg51.h"
#include <string.h>
#include"ziku.h"
#define uchar unsigned char
#define LCD_DB P0
sbit cs1=P3^2;
sbit cs2=P3^3;
sbit cs3=P3^4;
sbit cs4=P3^5;
sbit rs=P2^6;
sbit rw=P2^5;
sbit e=P2^7;
void wrcomleft(uchar);
void wrcomright(uchar);
void wrcomleftdown(uchar);
void wrcomrightdown(uchar);
void wrdataleft(uchar);
void wrdataright(uchar);
void wrdataleftdown(uchar);
void wrdatarightdown(uchar);
void busycheck();
void disp(uchar,uchar,uchar);
void cursor(uchar, uchar);
delay1ms(int t);
void clc_screen();
main()
{
uchar *p;
P1 &= 0xf0;
clc_screen();
while(1)
{
p=&ye;
disp(0xbe,0x40,p);
p=&ye;
disp(0xbe,0x50,p);
p=&ye;
disp(0xbe,0x60,p);
p=&ye;
disp(0xbe,0x70,p);
p=&ye;
disp(0xbe,0x80,p);
p=&ye;
disp(0xbe,0xa8,p);
p=&ye;
disp(0xbe,0xd0,p);
}
}
void disp(uchar page, uchar col, uchar *p)
{
int i;
if(col<0x80)
{
wrcomleft(0x3f);
wrcomleft(page);
wrcomleft(col);
for(i=0;i<16;i++)
{
wrdataleft(p);
}
wrcomleft(page+1);
wrcomleft(col);
for(i=16;i<32;i++)
{
wrdataleft(p);
}
}
if(col>0x7f && col<0xA8)
{
col=col-64;
wrcomright(0x3f);
wrcomright(page);
wrcomright(col);
for(i=0;i<16;i++)
{
wrdataright(p);
}
wrcomright(page+1);
wrcomright(col);
for(i=16;i<32;i++)
{
wrdataright(p);
}
}
if(col>0xA7 && col<0xD0)
{
col=col-104;
wrcomleftdown(0x3f);
wrcomleftdown(page);
wrcomleftdown(col);
for(i=0;i<16;i++)
{
wrdataleftdown(p);
}
wrcomleftdown(page+1);
wrcomleftdown(col);
for(i=16;i<32;i++)
{
wrdataleftdown(p);
}
}
if(col>0xCf && col<0xF8)
{
col=col-144;
wrcomrightdown(0x3f);
wrcomrightdown(page);
wrcomrightdown(col);
for(i=0;i<16;i++)
{
wrdatarightdown(p);
}
wrcomrightdown(page+1);
wrcomrightdown(col);
for(i=16;i<32;i++)
{
wrdatarightdown(p);
}
}
}
void clc_screen()// ???áoˉêy
{
int i,j;
wrcomleft(0x3f);
wrcomright(0x3f);
wrcomleftdown(0x3f);
wrcomrightdown(0x3f);
for(i=0;i<8;i++)
{
wrcomleft(0xb8+i);
wrcomright(0xb8+i);
wrcomleft(0x40);
wrcomright(0x40);
wrcomleftdown(0xb8+i);
wrcomrightdown(0xb8+i);
wrcomleftdown(0x40);
wrcomrightdown(0x40);
for(j=0;j<0x40;j++)
{
wrdataleft(0);
wrdataright(0);
wrdataleftdown(0);
wrdatarightdown(0);
}
}
}
void wrcomleft(uchar h)//×ó??D′??á?3ìDò
{
cs1=0;
cs2=1;
cs3=0;
cs4=0;
rw=0; //D′óDD§
rs=0; //D′??á?×′ì?
LCD_DB=h;
delay1ms(0);
e=1;
delay1ms(0);
e=0; //e ???μ??D′è?êy?Y
}
void wrcomright(uchar l)// óò??D′??á?3ìDò
{
cs1=1;
cs2=0;
cs3=0;
cs4=0;
e=1;
rw=0;//D′óDD§
rs=0;//D′??á?×′ì?
LCD_DB=l;
delay1ms(0);
e=1;
delay1ms(0);
e=0; //e ???μ??D′è?êy?Y
}
void wrcomleftdown(uchar h)//×ó??D′??á?3ìDò
{
cs1=0;
cs2=0;
cs3=0;
cs4=1;
rw=0; //D′óDD§
rs=0; //D′??á?×′ì?
LCD_DB=h;
delay1ms(0);
e=1;
delay1ms(0);
e=0; //e ???μ??D′è?êy?Y
}
void wrcomrightdown(uchar l)// óò??D′??á?3ìDò
{
cs1=0;
cs2=0;
cs3=1;
cs4=0;
e=1;
rw=0;//D′óDD§
rs=0;//D′??á?×′ì?
LCD_DB=l;
delay1ms(0);
e=1;
delay1ms(0);
e=0; //e ???μ??D′è?êy?Y
}
void wrdataleft(uchar k)// ×ó??D′êy?Y3ìDò
{
cs1=0;
cs2=1;
cs3=0;
cs4=0;
rw=0; //D′óDD§
rs=1; //D′êy?Y×′ì?
LCD_DB=k;
delay1ms(0);
e=1;
delay1ms(0);
e=0; //e ???μ??D′è?êy?Y
}
void wrdataright(uchar j)// óò??D′êy?Y3ìDò
{
cs1=1;
cs2=0;
cs3=0;
cs4=0;
e=1;
rw=0; //D′óDD§
rs=1; //D′êy?Y×′ì?
LCD_DB=j;
delay1ms(0);
e=1;
delay1ms(0);
e=0; //e ???μ??D′è?êy?Y
}
void wrdataleftdown(uchar k)// ×ó??D′êy?Y3ìDò
{
cs1=0;
cs2=0;
cs3=0;
cs4=1;
rw=0; //D′óDD§
rs=1; //D′êy?Y×′ì?
LCD_DB=k;
delay1ms(0);
e=1;
delay1ms(0);
e=0; //e ???μ??D′è?êy?Y
}
void wrdatarightdown(uchar j)// óò??D′êy?Y3ìDò
{
cs1=0;
cs2=0;
cs3=1;
cs4=0;
e=1;
rw=0; //D′óDD§
rs=1; //D′êy?Y×′ì?
LCD_DB=j;
delay1ms(0);
e=1;
delay1ms(0);
e=0; //e ???μ??D′è?êy?Y
}
delay1ms(int t)
{
int i,j;
for(i=0;i<t;i++)
for(j=0;j<120;j++)
;
}
7.驱动的修改与移植
我要移植到Arduino IDE上面,这样方便减少开发时间。
VO不用连接,然后测试时候应该A和K也不用连。
我在上面一个为基础的情况下修改了代码,但是,不能正常的驱动,因为接线或者其他什么原因,VCC和GND的电压一直不够。不管怎么样,当做一个参考来吧
?
#include <Arduino.h>
#define RS 2
#define EN 3
#define RW 4
#define I0 5
#define I2 6
#define I1 7
#define I3 8
#define I4 9
#define I6 10
#define I5 11
#define I7 12
#define CS1 13
#define CS3 A0
#define CS2 A1
#define CS4 A2
#define uchar unsigned char
void wrcomleft(uchar);
void wrcomright(uchar);
void wrcomleftdown(uchar);
void wrcomrightdown(uchar);
void wrdataleft(uchar);
void wrdataright(uchar);
void wrdataleftdown(uchar);
void wrdatarightdown(uchar);
void busycheck();
void disp(uchar,uchar,uchar);
void cursor(uchar, uchar);
void delay1ms(int t);
void clc_screen();
void maintest();
void lg(String s)
{
Serial.println(s);
}
void LCD_DB(uchar u)
{
digitalWrite(I0,u&0x01);
digitalWrite(I1,u>>1&0x01);
digitalWrite(I2,u>>2&0x01);
digitalWrite(I3,u>>3&0x01);
digitalWrite(I4,u>>4&0x01);
digitalWrite(I5,u>>5&0x01);
digitalWrite(I6,u>>6&0x01);
digitalWrite(I7,u>>7&0x01);
Serial.println("Run Lcd_db");
}
void pinInit()
{
for(int i=2;i<=13;i++)
{
pinMode(i,OUTPUT);
digitalWrite(i,HIGH);
}
for(int i=A0;i<=A4;i++)
{
pinMode(i,OUTPUT);
digitalWrite(i,HIGH);
}
Serial.println("Pininit");
}
void logicInit()
{
for(int i=13;i<=A4;i++)
{
digitalWrite(i,HIGH);
}
Serial.println("Set pin high");
}
void disp(uchar page, uchar col, uchar *p)
{
int i;
lg("Run disp");
if(col<0x80)
{
wrcomleft(0x3f);
wrcomleft(page);
wrcomleft(col);
for(i=0;i<16;i++)
{
wrdataleft(p);
}
wrcomleft(page+1);
wrcomleft(col);
for(i=16;i<32;i++)
{
wrdataleft(p);
}
}
if(col>0x7f && col<0xA8)
{
col=col-64;
wrcomright(0x3f);
wrcomright(page);
wrcomright(col);
for(i=0;i<16;i++)
{
wrdataright(p);
}
wrcomright(page+1);
wrcomright(col);
for(i=16;i<32;i++)
{
wrdataright(p);
}
}
if(col>0xA7 && col<0xD0)
{
col=col-104;
wrcomleftdown(0x3f);
wrcomleftdown(page);
wrcomleftdown(col);
for(i=0;i<16;i++)
{
wrdataleftdown(p);
}
wrcomleftdown(page+1);
wrcomleftdown(col);
for(i=16;i<32;i++)
{
wrdataleftdown(p);
}
}
if(col>0xCf && col<0xF8)
{
col=col-144;
wrcomrightdown(0x3f);
wrcomrightdown(page);
wrcomrightdown(col);
for(i=0;i<16;i++)
{
wrdatarightdown(p);
}
wrcomrightdown(page+1);
wrcomrightdown(col);
for(i=16;i<32;i++)
{
wrdatarightdown(p);
}
}
lg("Disp over");
}
void clc_screen()// ???áoˉêy
{
int i,j;
wrcomleft(0x3f);
wrcomright(0x3f);
wrcomleftdown(0x3f);
wrcomrightdown(0x3f);
for(i=0;i<8;i++)
{
wrcomleft(0xb8+i);
wrcomright(0xb8+i);
wrcomleft(0x40);
wrcomright(0x40);
wrcomleftdown(0xb8+i);
wrcomrightdown(0xb8+i);
wrcomleftdown(0x40);
wrcomrightdown(0x40);
for(j=0;j<0x40;j++)
{
wrdataleft(0);
wrdataright(0);
wrdataleftdown(0);
wrdatarightdown(0);
}
}
}
void wrcomleft(uchar h)//×ó??D′??á?3ìDò
{
digitalWrite(CS1,LOW);
digitalWrite(CS2,HIGH);
digitalWrite(CS3,LOW);
digitalWrite(CS4,LOW);
digitalWrite(RW,LOW); //D′óDD§
digitalWrite(RS,LOW); //D′??á?×′ì?
LCD_DB(h);
delay1ms(0);
digitalWrite(EN,HIGH);
delay1ms(0);
digitalWrite(EN,LOW); //e ???μ??D′è?êy?Y
}
void wrcomright(uchar l)// óò??D′??á?3ìDò
{
digitalWrite(CS1,HIGH);
digitalWrite(CS2,LOW);
digitalWrite(CS3,LOW);
digitalWrite(CS4,LOW);
digitalWrite(EN,HIGH);
digitalWrite(RW,LOW);//D′óDD§
digitalWrite(RS,LOW);//D′??á?×′ì?
LCD_DB(l);
delay1ms(0);
digitalWrite(EN,HIGH);
delay1ms(0);
digitalWrite(EN,LOW); //e ???μ??D′è?êy?Y
}
void wrcomleftdown(uchar h)//×ó??D′??á?3ìDò
{
digitalWrite(CS1,LOW);
digitalWrite(CS2,LOW);
digitalWrite(CS3,LOW);
digitalWrite(CS4,HIGH);
digitalWrite(RW,LOW); //D′óDD§
digitalWrite(RS,LOW); //D′??á?×′ì?
LCD_DB(h);
delay1ms(0);
digitalWrite(EN,HIGH);
delay1ms(0);
digitalWrite(EN,LOW); //e ???μ??D′è?êy?Y
}
void wrcomrightdown(uchar l)// óò??D′??á?3ìDò
{
digitalWrite(CS1,LOW);
digitalWrite(CS2,LOW);
digitalWrite(CS3,HIGH);
digitalWrite(CS4,LOW);
digitalWrite(EN,HIGH);
digitalWrite(RW,LOW);//D′óDD§
digitalWrite(RS,LOW);//D′??á?×′ì?
LCD_DB(l);
delay1ms(0);
digitalWrite(EN,HIGH);
delay1ms(0);
digitalWrite(EN,LOW); //e ???μ??D′è?êy?Y
}
void wrdataleft(uchar k)// ×ó??D′êy?Y3ìDò
{
digitalWrite(CS1,LOW);
digitalWrite(CS2,HIGH);
digitalWrite(CS3,LOW);
digitalWrite(CS4,LOW);
digitalWrite(RW,LOW); //D′óDD§
digitalWrite(RS,HIGH); //D′êy?Y×′ì?
LCD_DB(k);
delay1ms(0);
digitalWrite(EN,HIGH);
delay1ms(0);
digitalWrite(EN,LOW); //e ???μ??D′è?êy?Y
}
void wrdataright(uchar j)// óò??D′êy?Y3ìDò
{
digitalWrite(CS1,HIGH);
digitalWrite(CS2,LOW);
digitalWrite(CS3,LOW);
digitalWrite(CS4,LOW);
digitalWrite(EN,HIGH);
digitalWrite(RW,LOW); //D′óDD§
digitalWrite(RS,HIGH); //D′êy?Y×′ì?
LCD_DB(j);
delay1ms(0);
digitalWrite(EN,HIGH);
delay1ms(0);
digitalWrite(EN,LOW); //e ???μ??D′è?êy?Y
}
void wrdataleftdown(uchar k)// ×ó??D′êy?Y3ìDò
{
digitalWrite(CS1,LOW);
digitalWrite(CS2,LOW);
digitalWrite(CS3,LOW);
digitalWrite(CS4,HIGH);
digitalWrite(RW,LOW); //D′óDD§
digitalWrite(RS,HIGH); //D′êy?Y×′ì?
LCD_DB(k);
delay1ms(0);
digitalWrite(EN,HIGH);
delay1ms(0);
digitalWrite(EN,LOW); //e ???μ??D′è?êy?Y
}
void wrdatarightdown(uchar j)// óò??D′êy?Y3ìDò
{
digitalWrite(CS1,LOW);
digitalWrite(CS2,LOW);
digitalWrite(CS3,HIGH);
digitalWrite(CS4,LOW);
digitalWrite(EN,HIGH);
digitalWrite(RW,LOW); //D′óDD§
digitalWrite(RS,HIGH); //D′êy?Y×′ì?
LCD_DB(j);
delay1ms(0);
digitalWrite(EN,HIGH);
delay1ms(0);
digitalWrite(EN,LOW); //e ???μ??D′è?êy?Y
}
void delay1ms(int t)
{
int i,j;
delay(t);
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
pinInit();
Serial.println("Pin Init Over");
delay(1000);
}
void loop()
{
maintest();
// put your main code here, to run repeatedly:
}
unsigned char ye[]=
{
0x10,0x61,0x86,0x60,0x84,0xE4,0x1C,0x84,0x45,0x3E,0xA4,0x24,0xE6,0x04,0x00,0x00,
0x02,0x3E,0x01,0x00,0x00,0x3F,0x21,0x20,0x11,0x0A,0x04,0x0B,0x10,0x20,0x00,0x00,
};
void maintest()
{
uchar *p;
clc_screen();
while(1)
{
logicInit();
p=ye;
disp(0xbe,0x40,p);
p=ye;
disp(0xbe,0x50,p);
p=ye;
disp(0xbe,0x60,p);
p=ye;
disp(0xbe,0x70,p);
p=ye;
disp(0xbe,0x80,p);
p=ye;
disp(0xbe,0xa8,p);
p=ye;
disp(0xbe,0xd0,p);
delay(100);
}
}
|