waleed.ahafeez
Joined: 16 Mar 2012 Posts: 10
|
|
Posted: Tue Apr 17, 2012 1:20 am |
|
|
Hi Jeremiah,
I am using PIC 18F452, with the following drivers for displaying data on the GLCD but don't how to use these drivers with Graphics header file, these drivers was provided by the GLCD manufacturers for 8051 Micro Controller, I changed the code to use with PIC 18F452 now it is displaying some data on the screen (but unfortunately most of data displaying on the screen is garbage) .
Code: |
#include<18F452.h>
#include<stdio.h>
#include<stdlib.h>
#use delay(clock=20000000)
#define uchar char
#define uint int
#DEFINE wr PIN_B0
#DEFINE rd PIN_B1
#DEFINE cs PIN_B2
#DEFINE cd PIN_B3
#DEFINE rst PIN_B4
uchar zimu[8][93]=
{
0, 0, 0, 0, 0, 0, 0, 0, //' '
0, 6, 95, 95, 6, 0, 0, 0, //'!'
0, 7, 7, 0, 7, 7, 0, 0, //'"'
20, 127, 127, 20, 127, 127, 20, 0, //'#'
36, 46, 107, 107, 58, 18, 0, 0, //'$'
70, 102, 48, 24, 12, 102, 98, 0, //'%'
48, 122, 79, 93, 55, 122, 72, 0, //'&'
4, 7, 3, 0, 0, 0, 0, 0, //'''
0, 28, 62, 99, 65, 0, 0, 0, //'('
0, 65, 99, 62, 28, 0, 0, 0, //')'
8, 42, 62, 28, 28, 62, 42, 8, //'*'
8, 8, 62, 62, 8, 8, 0, 0, //'+'
0, 128, 224, 96, 0, 0, 0, 0, //','
8, 8, 8, 8, 8, 8, 0, 0, //'-'
0, 0, 96, 96, 0, 0, 0, 0, //'.'
96, 48, 24, 12, 6, 3, 1, 0, //'/'
62, 127, 113, 89, 77, 127, 62, 0, //'0'
64, 66, 127, 127, 64, 64, 0, 0, //'1'
98, 115, 89, 73, 111, 102, 0, 0, //'2'
34, 99, 73, 73, 127, 54, 0, 0, //'3'
24, 28, 22, 83, 127, 127, 80, 0, //'4'
39, 103, 69, 69, 125, 57, 0, 0, //'5'
60, 126, 75, 73, 121, 48, 0, 0, //'6'
3, 3, 113, 121, 15, 7, 0, 0, //'7'
54, 127, 73, 73, 127, 54, 0, 0, //'8'
6, 79, 73, 105, 63, 30, 0, 0, //'9'
0, 0, 102, 102, 0, 0, 0, 0, //':'
0, 128, 230, 102, 0, 0, 0, 0, //';'
8, 28, 54, 99, 65, 0, 0, 0, //'<'
36, 36, 36, 36, 36, 36, 0, 0, //'='
0, 65, 99, 54, 28, 8, 0, 0, //'>'
2, 3, 81, 89, 15, 6, 0, 0, //'?'
62, 127, 65, 93, 93, 31, 30, 0, //'@'
124, 126, 19, 19, 126, 124, 0, 0, //'A'
65, 127, 127, 73, 73, 127, 54, 0, //'B'
28, 62, 99, 65, 65, 99, 34, 0, //'C'
65, 127, 127, 65, 99, 62, 28, 0, //'D'
65, 127, 127, 73, 93, 65, 99, 0, //'E'
65, 127, 127, 73, 29, 1, 3, 0, //'F'
28, 62, 99, 65, 81, 115, 114, 0, //'G'
127, 127, 8, 8, 127, 127, 0, 0, //'H'
0, 65, 127, 127, 65, 0, 0, 0, //'I'
48, 112, 64, 65, 127, 63, 1, 0, //'J'
65, 127, 127, 8, 28, 119, 99, 0, //'K'
65, 127, 127, 65, 64, 96, 112, 0, //'L'
127, 127, 14, 28, 14, 127, 127, 0, //'M'
127, 127, 6, 12, 24, 127, 127, 0, //'N'
28, 62, 99, 65, 99, 62, 28, 0, //'O'
65, 127, 127, 73, 9, 15, 6, 0, //'P'
30, 63, 33, 113, 127, 94, 0, 0, //'Q'
65, 127, 127, 9, 25, 127, 102, 0, //'R'
38, 111, 77, 89, 115, 50, 0, 0, //'S'
3, 65, 127, 127, 65, 3, 0, 0, //'T'
127, 127, 64, 64, 127, 127, 0, 0, //'U'
31, 63, 96, 96, 63, 31, 0, 0, //'V'
127, 127, 48, 24, 48, 127, 127, 0, //'W'
67, 103, 60, 24, 60, 103, 67, 0, //'X'
7, 79, 120, 120, 79, 7, 0, 0, //'Y'
71, 99, 113, 89, 77, 103, 115, 0, //'Z'
0, 127, 127, 65, 65, 0, 0, 0, //'['
1, 3, 6, 12, 24, 48, 96, 0, //'\'
0, 65, 65, 127, 127, 0, 0, 0, //']'
8, 12, 6, 3, 6, 12, 8, 0, //'^'
128, 128, 128, 128, 128, 128, 128, 128, //'_'
0, 0, 3, 7, 4, 0, 0, 0, //'`'
32, 116, 84, 84, 60, 120, 64, 0, //'a'
65, 127, 63, 72, 72, 120, 48, 0, //'b'
56, 124, 68, 68, 108, 40, 0, 0, //'c'
48, 120, 72, 73, 63, 127, 64, 0, //'d'
56, 124, 84, 84, 92, 24, 0, 0, //'e'
72, 126, 127, 73, 3, 2, 0, 0, //'f'
152, 188, 164, 164, 248, 124, 4, 0, //'g'
65, 127, 127, 8, 4, 124, 120, 0, //'h'
0, 68, 125, 125, 64, 0, 0, 0, //'i'
96, 224, 128, 128, 253, 125, 0, 0, //'j'
65, 127, 127, 16, 56, 108, 68, 0, //'k'
0, 65, 127, 127, 64, 0, 0, 0, //'l'
124, 124, 24, 56, 28, 124, 120, 0, //'m'
124, 124, 4, 4, 124, 120, 0, 0, //'n'
56, 124, 68, 68, 124, 56, 0, 0, //'o'
132, 252, 248, 164, 36, 60, 24, 0, //'p'
24, 60, 36, 164, 248, 252, 132, 0, //'q'
68, 124, 120, 76, 4, 28, 24, 0, //'r'
72, 92, 84, 84, 116, 36, 0, 0, //'s'
0, 4, 62, 127, 68, 36, 0, 0, //'t'
60, 124, 64, 64, 60, 124, 64, 0, //'u'
28, 60, 96, 96, 60, 28, 0, 0, //'v'
60, 124, 112, 56, 112, 124, 60, 0, //'w'
68, 108, 56, 16, 56, 108, 68, 0, //'x'
156, 188, 160, 160, 252, 124, 0, 0, //'y'
76, 100, 116, 92, 76, 100, 0, 0, //'z'
8, 8, 62, 119, 65, 65, 0, 0, //'{'
0, 0, 0, 119, 119, 0, 0, 0, //'|'
};
void write(int1 flag,int dat)
{
output_low(cs);
if (flag==0)
output_low(cd);
if (flag==1)
output_high(cd);
output_low(wr);
output_high(rd);
output_d(dat);
output_high(wr);
}
void init(void)//*
{
output_low(cs);
/*reset*/
output_low(rst);
delay_ms(2); //power on reset
output_high(rst);
delay_ms(200);
write(0,0xe2); //reset by command
delay_ms(2);
/*power control*/
write(0,0xe9); //(26)Bias Ratio:1/10 bias
write(0,0x2b); //(6)power control set as internal power
write(0,0x25); //(5)set temperate compensation as 0%
write(0,0x81); //(10)electronic potentionmeter
write(0,0xbf);
/*display control*/
write(0,0xa4); //(15)all pixel off
write(0,0xa6); //(16)inverse display off
/*lcd control*/
write(0,0xc0); //(18)partial display and MX disable,MY enable
write(0,0xa3); //(14)line rate 15.2klps
write(0,0xd1); //(20)rgb-rgb
write(0,0xd5); //(21)4k color mode
write(0,0x84); //(11)partial display control disable
/*(19)n-line inversion*/
write(0,0xc8);
write(0,0x10); //enable NIV
/*(22)com scan fuction*/
write(0,0xda); //enable FRC,PWM,LRM sequence
/*window*/
write(0,0xf4); //(30)wpc0:column
write(0,0x25); //start from 130
write(0,0xf6); //(32)wpc1
write(0,0x5a); //end:272
write(0,0xf5); //(31)wpp0:row
write(0,0x00); //start from 0
write(0,0xf7); //(32)wpP0
write(0,0x9F); //end 160
write(0,0xf8); //(34)inside mode AC3
write(0,0x89); //(12)RAM control,ÏÔʾ·½Ïò
write(0,0xad); //(17)display on,select on/off mode.Green Enhance mode disable
/*scroll line Óë RAM µÄÓ³Éä¹Øϵ*/
write(0,0x40); //(8)low bit of scroll line
write(0,0x50); //high bit of scroll line
write(0,0xc4); //(18)partial display and MX disable,MY enable
write(0,0x90); //(13):FLT,FLB set
write(0,0x00);
/*partial display*/
write(0,0x84); //(11),set partial display control:off
write(0,0xf1); //(27)com end
write(0,0x9f); //160
write(0,0xf2); //(28)display start
write(0,0); //0
write(0,0xf3); //(29)display end
write(0,159); //160
}
void words(uchar x,uchar y,uchar *p) //type=1,ascii;type=2,Chinese character
{
uchar i,k,j,m,n,l,x0,dat0,dat1,dat2,dat3,dat4,dat5,dat6;
x=37+x;
x0=0x00|(x&0x0f);
x=0x10|((x&0xf0)>>4);
for(j=0;j<8;j++)
{
m=i*8+j;
write(0,0x89);//SET RAM ADDRESS CONTROL
write(0,x0);//Set Column Address LSB CA[3:0]
write(0,x);//Set Column Address MSB CA[7:4]
write(0,0x60|((y+m)&0x0f));//Set Row Address LSB RA [3:0]
write(0,0x70|(((y+m)&0xf0)>>4));//Set Row Address MSB RA [7:4]
for(k=0;k<2;k++)
{
l=k*6+n;
dat6=0x01<<j;
dat0=(*(p+l))&dat6;
dat0=dat0>>j;
dat0<<=7;
dat1=(*(p+l+1))&dat6;
dat1=dat1>>j;
dat1<<=3;
dat2=*(p+2+l)&dat6;
dat2=dat2>>j;
dat2<<=7;
dat3=(*(p+3+l))&dat6;
dat3=dat3>>j;
dat3<<=3;
dat4=(*(p+4+l))&dat6;
dat4=dat4>>j;
dat4<<=7;
dat5=(*(p+5+l))&dat6;
dat5=dat5>>j;
dat5<<=3;
write(1,dat0|dat1);
write(1,dat2|dat3);
write(1,dat4|dat5);
}
write(0,0x88);//SET RAM ADDRESS CONTROL
}
write(0,0x89);//SET RAM ADDRESS CONTROL
}
void lcdscan(uchar dat1,uchar dat2)
{
uchar i,j;
write(0,0x60); //row address LSB
write(0,0x70); //row address MSB
write(0,0x05); //culomn address LSB
write(0,0x12); //culomn address MSB
for(j=0;j<160;j++)
{
for(i=0;i<27;i++)
{
if(j%2==0)
{
write(1,dat1);
write(1,dat1);
write(1,dat1);
}
else
{
write(1,dat2);
write(1,dat2);
write(1,dat2);
}
}
}
}
void character(void)
{
uchar *q;
uchar i,j;
lcdscan(0x00,0x00);
for(i=0;i<8;i++)//controller:
{
q=zimu[i];
j=4*i+4;
words(j,0,q);
}
for(i=11;i<18;i++)//uc1698u
{
q=zimu+i*36;
j=4*(i-11)+4;
words(j,70,q);
}
}
void main(void)
{
init();
character();
delay_ms(1000);
} |
|
|