• We recently switched our forum platform. If you experience any issues please email support@crystalfontz.com

Problem while initializing graphic lcd --- GDM12864A ™ LCM

saitm

New member
Hi,
I am uisng 'GDM12864A ™ LCM' lcd module interfaced to arm board.
I am facing problem initialising the page on CS2.
Can anyone tell where the problem is.

#define LOOPCNT 50
unsigned int DATA;
unsigned int COM;
struct _MAT91S_PIO *psys;
void delay1(void)
{
unsigned int Ucch;
Ucch = 0xff;
while(Ucch--);
}//11.60 micro seconds

void delay2(int cnt){
int k;
for (k=0;k<cnt;k++ )
{
delay1();
}
}

void WrPortI(unsigned int value){
if (value&0x80) {//DB7
psys->PIOB_SODR=DB7_PB3_HI;
} else {
psys->PIOB_CODR=DB7_PB3_HI;
}

if (value&0x40) {//DB6
psys->PIOB_SODR=DB6_PB16_HI;
} else {
psys->PIOB_CODR=DB6_PB16_HI;
}

if (value&0x20) {//DB5
psys->PIOB_SODR=DB5_PB17_HI;
} else {
psys->PIOB_CODR=DB5_PB17_HI;
}

if (value&0x10) {//DB4
psys->PIOB_SODR=DB4_PB18_HI;
} else {
psys->PIOB_CODR=DB4_PB18_HI;
}

if (value&0x08) {//DB3
psys->PIOC_SODR =DB3_PC0_HI;
} else {
psys->PIOC_CODR =DB3_PC0_HI;
}

if (value&0x04) {//DB2
psys->PIOC_SODR =DB2_PC1_HI;
} else {
psys->PIOC_CODR =DB2_PC1_HI;
}

if (value&0x02) {//DB1
psys->PIOC_SODR =DB1_PC6_HI;
} else {
psys->PIOC_CODR =DB1_PC6_HI;
}

if (value&0x01) {//DB0
psys->PIOC_SODR =DB0_PC7_HI;
} else {
psys->PIOC_CODR =DB0_PC7_HI;
}
}// write data into data register



void right_com(void)
{
int a,i;
psys->PIOB_SODR = CS1_PB2_HI;// CS_1_1
psys->PIOB_CODR = CS2_PB1_HI;// CS_2_0
psys->PIOC_CODR =DI_PC15_HI; // DI low
psys->PIOC_SODR = RW_PC9_HI;// READ_MODE // for reading busy flag
delay1();
psys->PIOC_CODR = RW_PC9_HI; //WRITE_MODE
WrPortI(COM);
delay2(LOOPCNT);
psys->PIOC_SODR =E_PC8_HI;// E pin high
delay2(LOOPCNT);
psys->PIOC_CODR =E_PC8_HI; // E pin low
delay2(LOOPCNT);
}
void right_write(void)
{
int a,i;
psys->PIOB_SODR = CS1_PB2_HI;//CS_1_1
psys->PIOB_CODR = CS2_PB1_HI;//CS_2_0
psys->PIOC_CODR =DI_PC15_HI;//DI low
psys->PIOC_SODR = RW_PC9_HI;//READ_MODE // for reading busy flag
delay1();
psys->PIOC_SODR =DI_PC15_HI;//DI high
psys->PIOC_CODR = RW_PC9_HI;//WRITE_MODE
WrPortI(DATA);
delay2(LOOPCNT);
psys->PIOC_SODR =E_PC8_HI;//E high
delay2(LOOPCNT);
psys->PIOC_CODR =E_PC8_HI;//E low
delay2(LOOPCNT);
}

void display_on(void)
{
COM = 0x3f;
right_com();
}

void display_off(void)
{
COM = 0x3e;
right_com();
}

void init(void)
{
int i,j;
psys->PIOB_CODR=RS_PB0_HI ;//E_RESET
for(j=0;j<3;j++)
for(i=0;i<255;i++)
delay1();

psys->PIOB_SODR=RS_PB0_HI ;//D_RESET
for(j=0;j<3;j++)
for(i=0;i<255;i++)
delay1();

display_on();

for(i=0xb8;i<=0xbf;i++)
{

COM=i; // page select
right_com();
COM = 0xC0; // start line // Z address
right_com();
COM = 0x40; //0x40 // Y address
right_com();
DATA = 0x00;
for(j=0;j<0x40;j++) //0x40
{
right_write();
}
}
}

/* START FUNCTION DESCRIPTION ********************************************
<.LIB>
SYNTAX: void show(void)
DESCRIPTION: THIS FUNCTION WRITES ALL THE DATAS WHICH ARE TO BE DISPLAYED
IN THIS CASE ALL "A" TO "Z" HAS BEEN DISPLAYED.THIS FUNCTION CAN BE
CHANGED BASED ON THE PATTERN TO BE DISPLAYED.
PARAMETER: NIL
RETURN VALUE: NIL
END DESCRIPTION **********************************************************/
void show(void)
{
/**************************************************************************
TO DISPLAY CHAR "A"
16X16 PIXEL CHOSEN IE. DATA HAS TO BE WRITTEN IN TWO PAGES

1.CHOOSE IST PAGE ie 0XB8 WHICH IS UPPER PART
2.IN 1ST PAGE CHOOSE 0X42 ie.FROM WHERE DATA HAS TO BE DISPLAYED IN X DIRECTION
(X FOR ME IS STANDARD X DIRECTION NOT AS IT IS MENTIONED IN DATASHEETS)
3. WRITE ALL THE DATA PIXELWISE TO IST PAGE WHICH INCREMENTS 'X'POSITION AUTOMATICALLY
***************************************************************************/
// for character "A"
// 1st line SET COMMAND
COM=0xb8; //page
right_com();
COM=0x42;//x direction
right_com();

DATA=0x00; //PIXEL WRITING 1
right_write();
DATA=0xC0; //2
right_write();
DATA=0xF0; //3
right_write();
DATA=0x3C; //4
right_write();
DATA=0x0F; //5
right_write();
DATA=0x0F; //6
right_write();
DATA=0x3C; //7
right_write();
DATA=0xF0; //8
right_write();
DATA=0xC0; //9
right_write();
DATA=0x00; //10
right_write();
/***************************************************************************
FOR LOWER PAGE 0XB9
1.CHOOSE 2ND PAGE ie 0XB9 WHICH IS LOWER PART
2.IN 2ND PAGE CHOOSE 0X42 ie.FROM WHERE DATA HAS TO BE DISPLAYED IN X DIRECTION
(X FOR ME IS STANDARD X DIRECTION NOT AS IT IS MENTIONED IN DATASHEETS)
3. WRITE ALL THE DATA PIXELWISE TO IST PAGE WHICH INCREMENTS 'X'POSITION AUTOMATICALLY

***************************************************************************/

COM=0xb9; // 2nd line SET COMMAND
right_com();
COM=0x42;
right_com();

DATA=0x0E; //PIXEL WRITING 1
right_write();
DATA=0x0F; //2
right_write();
DATA=0x01; //3
right_write();
DATA=0x01; //4
right_write();
DATA=0x01; //5
right_write();
DATA=0x01; //6
right_write();
DATA=0x01; //7
right_write();
DATA=0x01; //8
right_write();
DATA=0x0F; //9
right_write();
DATA=0x0E; //10
right_write();
}



void main()
{

int fd,i,j;

void *map_base,*virt_addr;

unsigned long read_result,writeval;
off_t target= 0xFFFFEA00;

if( (fd= open("/dev/mem",O_RDWR | O_SYNC ) ) == -1) FATAL;
printf("/dev/mem opened\n");
fflush(stdout);


/* map one page*/
map_base = mmap(0,MAP_SIZE,PROT_READ | PROT_WRITE,MAP_SHARED,fd,target & ~MAP_MASK);
if(map_base == (void *) -1) FATAL;
printf("Memory mapped at address %p.\n",map_base);
fflush(stdout);
virt_addr = map_base + (target & MAP_MASK);

psys = (volatile unsigned long *)virt_addr;

psys->PIOC_PER= DI_PC15_HI |RW_PC9_HI | E_PC8_HI | DB0_PC7_HI | DB1_PC6_HI | DB2_PC1_HI | DB3_PC0_HI ; //PIO Enable Register
psys->PIOC_OER= DI_PC15_HI |RW_PC9_HI | E_PC8_HI | DB0_PC7_HI | DB1_PC6_HI | DB2_PC1_HI | DB3_PC0_HI ; //output Enable register

psys->PIOB_PER= DB4_PB18_HI | DB5_PB17_HI | DB6_PB16_HI | DB7_PB3_HI | CS1_PB2_HI |CS2_PB1_HI|RS_PB0_HI ; //PIO Enable Register
psys->PIOB_OER= DB4_PB18_HI | DB5_PB17_HI | DB6_PB16_HI | DB7_PB3_HI | CS1_PB2_HI |CS2_PB1_HI|RS_PB0_HI;//output Enable register


init();
show();
display_on();
while(1); //CONTINUOUS WHILE LOOP TO OBSERVE THE DISPLAY

}







Thanks in advance,
saitm
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 
Last edited:
Top