MSP430液晶SED1335控制器程序
扫描二维码
随时随地手机看文章
//------------------------------------------------------------
//MSP430子程序(液晶控制器子程序)
//声明:转载请保留以上信息,用于商业用途,请联系作者
//------------------------------------------------------------
//ControlSED1335
//Functionshow
//------------------------------------------------------------
#defineWC_ADDXBYTE[0xC100]
#defineWD_ADDXBYTE[0xC000]
#defineRD_ADDXBYTE[0xC100]
#defineRB_ADDXBYTE[0xC000]
voidINTR(void);
voidCLEAR(void);/*信号输入x[0---319],y[0---239]*/
voidCCTW(unsignedintx,unsignedchary,unsignedcharm,unsignedcharn,unsignedchar*p);
voiddot(unsignedintx,unsignedchary,bitc);/*c=1划点c=0取消点*/
voidINTR(void)
{
unsignedcharcodeSYSTAB[]={0x30,0x87,0x07,0x27,0x42,0xf0,0x28,0x00};//controlparameter
unsignedcharcodeSCRTAB[]={0x00,0x00,0xf0,0x00,0x40,0xf0,0x00,0x80,0x00,0x00};
unsignedchari=0x0;
WC_ADD=0x40;
for(i=0;i<8;i++)
{
WD_ADD=SYSTAB;
}
WC_ADD=0x44;
for(i=0;i<10;i++)
{
WD_ADD=SCRTAB;
}
WC_ADD=0x5a;
WD_ADD=0x0;
WC_ADD=0x5b;
WD_ADD=0x0;
WC_ADD=0x59;
WD_ADD=0x54;
}
voidCLEAR(void)
{
unsignedchari=0,j=0;
WC_ADD=0x4c;
WC_ADD=0x46;
WD_ADD=0x0;
WD_ADD=0x0;
WC_ADD=0x42;
for(i=0;i<255;i++)
{
for(j=0;j<255;j++)
{WD_ADD=0x0;
}
}
}
voidCCTW(unsignedintx,unsignedchary,unsignedcharm,unsignedcharn,unsignedchar*p)
{
unsignedcharap=0x28,i,j,k,tt=0,uu=0,rr=0,ee=0,ff=0,gg=0;/*ap修改P7,行字符个数*/
unsignedintl;
tt=x%8;
x=x/8;
l=y*ap+x+0x4000;
x=(unsignedchar)(l&0x00ff);
y=(unsignedchar)((l&0xff00)>>8);
WC_ADD=0x4c;/*设置光标“右”移动方式*/
for(i=0;i
WC_ADD=0x46;/*光标指针设置*/
WD_ADD=x;/*光标地址16位*/
WD_ADD=y;
if(tt==0)
{
WC_ADD=0x42;/*连续写入数据*/
for(j=0;j
WD_ADD=*p;
p++;
}
}/*0123*/
else{/*0---78---1617---2425---32*/
for(j=0;j
RD_ADD=0x43;/*读数据*/
uu=RD_ADD;
rr=RD_ADD;
/*-----------------------------------------------------*/
gg=*p;/*处理数据*/
p++;
k=uu>>(8-tt);
k=k<<(8-tt);//高位
ee=k;
k=gg>>tt;//移高位作为低位
ee=ee|k;
/*-----------*/
k=rr<k=k>>tt;//低位
ff=k;
k=gg<<(8-tt);
ff=ff|k;
/*--------------------------------------------------------------*/
WC_ADD=0x4d;/*改变光标“左”移动方式*/
RD_ADD=0x43;
k=RD_ADD;
k=RD_ADD;
WC_ADD=0x4c;/*非复光标“右”移动方式*/
WC_ADD=0x42;/*送数据两个*/
WD_ADD=ee;
WD_ADD=ff;
/*本送一个数据,前面送了两个,需要返回一个*/
WC_ADD=0x4d;/*改变光标“左”移动方式*/
RD_ADD=0x43;
k=RD_ADD;
k=RD_ADD;
WC_ADD=0x4c;/*非复光标“右”移动方式*/
RD_ADD=0x43;
k=RD_ADD;
}
}
l=(ap+x+(y<<8));
x=(unsignedchar)(l&0x00ff);
y=(unsignedchar)((l&0xff00)>>8);
}
}
voiddot(unsignedintx,unsignedchary,bitc)
{
unsignedcharap=0x28,tt=0,uu=0,gg=0,k=0;/*ap修改P7,行字符个数*/
unsignedintl=0;
tt=x%8;
x=x/8;
l=y*ap+x+0x4000;
x=(unsignedchar)(l&0x00ff);
y=(unsignedchar)((l&0xff00)>>8);
WC_ADD=0x4c;
WC_ADD=0x46;/*光标指针设置*/
WD_ADD=x;/*光标地址16位*/
WD_ADD=y;
RD_ADD=0x43;/*读数据*/
uu=RD_ADD;
if(c)
{
gg=1;
gg=gg<<(7-tt);
uu=uu|gg;
}
else{
gg=1;
gg=gg<<(7-tt);
gg=~gg;
uu=uu≫
}
WC_ADD=0x4d;
RD_ADD=0x43;
k=RD_ADD;
WC_ADD=0x4c;/*非复光标“右”移动方式*/
WC_ADD=0x42;/*送数据两个*/
WD_ADD=uu;
}