谁用过力先 10脚的12864cog液晶屏,一直点不亮是什么原因,上电不亮,
程序如下
#define CS LATBbits.LATB5
#define RS LATBbits.LATB8
#define SCL LATAbits.LATA4
#define SDI LATAbits.LATA7
#define key1 LATAbits.LATA0
#define key2 LATAbits.LATA1
#define pause LATBbits.LATB3
#define RES LATBbits.LATB15
#define uchar unsigned char
#define uint unsigned int
void writec (uchar );
void stop(void);
void writed(uchar );
//void writed(uchar dat);
void flash(unsigned int t);
void init ( );
void display(uchar dat1,uchar dat2);
void displaychar(uchar *p);
const uchar chara1[] = {"www.txmcu.com"};
uchar vop=0x29;
void delay1(unsigned int t)
{
while(t>0)
{
t--; //TT- `
pause=1;
if(pause==0)stop();
}
}
int main(void)
{
delay1(1000);
writec(0xaf);
vop=0x29; //vop=9.1V
//vop=0x15; //vop=7.1V
init();
while (1)
{
display(0xff,0xff);
display(0x00,0x00);
display(0x55,0xaa);
display(0xaa,0x55);
displaychar(chara1);
// displaychar(chara2);//vop_test();
}
}
void flash(unsigned int t)
{
while(t>0)
{
t--; //TT- `
}
}
//-----------------------------
void stop()
{
flash(100);
while(pause==0)
{
pause=1;
key1=1;
key2=1;
if(key1==0)
{
flash(200);
if(key1==0)
{
while(key1==0);
flash(100);
if(vop<63)
{
vop++;
writec(0x81);
writec(vop);}
}
}
else if(key2==0)
{
flash(100);
if(key2==0)
{
while(key2==0);
flash(100);
if(vop>0)
{
vop--;
writec(0x81);
writec(vop);
}
}
}
}
}
void writec(uchar com)
{ unsigned char i ;
CS=0;
RS=0;
for(i=0;i<8;i++)
{ com=com<<1;
// SDI=SR.C;
SCL=1;
SCL=0;
}
CS=1;
RS=1;
}
void writed(uchar dat)
{ unsigned char i;
CS=0;
RS=1;
for(i=0;i<8;i++)
{
dat=dat<<1;
// SDI=SR.C;
SCL=1;
SCL=0;
}
CS=1;
RS=1;
}
void init ( )
{ LATA=0;
LATB = 0;
CNPU2bits.CN22PUE = 1;
CNPU2bits.CN21PUE = 1;
ANSA = 1;
ANSB = 0;
uchar col;
RES=1;
flash(1000);
RES=0;
flash(2000);
RES=1;
flash(1000);
writec(0xe3); // reset signal
writec(0xa3); //(0xa2 1/9 bias,1/65 duty )
writec(0xa0); // ADC select
writec(0xc8); // command output select
writec(0x2f); // power control
writec(0x24); // select resistor ratio Rb/Ra
writec(0x81); // select volume
writec(vop); // vop
writec(0xf8); // x4
writec(0x08); // x4
writec(0xb0);//set page address
writec(0x10);//set column address
writec(0x00);
for(col=0;col<128;col++)
{
writed(0x00);
}
writec(0xaf); //display on
}
void display(uchar dat1,uchar dat2)
{
uchar row,col;
for (row=0xb0; row<0xb8; row++) //0XB0 0XB8
{
writec(row);//set page address
writec(0x10);//set column address
writec(0x00);
for(col=0;col<128;col++)
{
writed(dat1);
writed(dat2);
}
}
delay1(50000);
}
void displaychar(uchar *p)
{
uchar row,col;
for (row=0xb0; row<0xb8; row++)
{
writec(row);//set page address
writec(0x10);//set column address
writec(0x00);
for(col=0;col<128;col++)
writed(*p++);
}
delay1(500);
}
此帖出自
小平头技术问答
一周热门 更多>