LCDInfo.com

http://www.lcdinfo.com
It is currently Fri Nov 22, 2024 4:13

All times are UTC + 2 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Mon Jan 03, 2005 7:28 
Offline

Joined: Mon Jan 03, 2005 7:04
Posts: 4
Location: South Korea
Dear All,

I am Designing New Display with Dataimage 128x64 Graphic LCD, But the problem is that it is showing the same text message on both side of Controller i.e CS1 & CS2 insteed of the hole message as string.Can anybody help me out.


with thanks in advance!
Anoop Tiwari[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 4:41 
Offline
User avatar

Joined: Fri Dec 03, 2004 7:03
Posts: 201
Location: Sydney, Australia
If you could provide more information on the model of the display, someone might be interested in taking a look for you. But if you leave all the work to us, then why would we bother? ;)

Model No. and any other info, links to datasheets...

Anyway. :) Hope to hear back from you soon. :)

_________________
Syridian,
http://syridian.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 13:19 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
How are you handling the CS1 and CS2 pins in your code ? Normally you should only have one side of the display enabled at a time as the display is made of two 64x64 parts and with the CS signals you select which one is currently used.


Top
 Profile  
 
PostPosted: Thu Jan 20, 2005 7:06 
Offline

Joined: Mon Jan 03, 2005 7:04
Posts: 4
Location: South Korea
[quote="Henri"]How are you handling the CS1 and CS2 pins in your code ? Normally you should only have one side of the display enabled at a time as the display is made of two 64x64 parts and with the CS signals you select which one is currently used

Pls check this code As I marked note in LCD_Write_Char Subroutine As(LCD_Page_Set() & LCD_Column_Set() ) After removing this 2 subroutines only half of display glow otherwise no Display at all.

/**************Start********************************/
#include <stdio.h>
#include <io320.h> // SFR declarations
#include <Font.h>

#define DISPLAY_ON 0x3F
#define DISPLAY_OFF 0x3E
#define DISPLAY_START_LINE 0xC0
#define DISPLAY_PAGE_SET 0xB8
#define DISPLAY_COLUMN_SET 0x40

sbit LCD_E = P3^0; //pin for Display Enable
sbit LCD_RS =P3^1; //pin for register select
sbit LCD_CS0 =P3^2; //pin for Controller1 Chip select
sbit LCD_CS1 =P3^3; //pin for Controller2 Chip select
sbit LCD_RW =P3^4; //pin for read/write


#define RIGHT 0
#define LEFT 1
#define BUSY 0x80
unsigned char CursorX, CursorY;

#define LINE1 0
#define LINE2 1
#define LINE3 2
#define LINE4 3
#define LINE5 4
#define LINE6 5
#define LINE7 6
#define LINE8 7


/****************SUB ROUTIENS**************************************/
void Delay(unsigned int wait);
void LCD_init(void);
void LCD_clear_scrn(void);
void LCD_test(void);
void LCD_Putstr(unsigned char *ptr);
void LCD_Page_Set(unsigned char xAddr);
void LCD_Column_Set(unsigned char yAddr);
void LCD_Data_Write(unsigned char Data);
void LCD_Start_Line(unsigned char start);
void LCD_Command_Write(unsigned char command);
void LCD_Write_Char(unsigned char c);
void LCD_Set_Address(unsigned char x,unsigned char y);
unsigned char LCD_Data_Read(void);
void LCD_Select_Side(unsigned char LcdSide);
void LCD_Wait_Busy(void);
void LCD_Set_Dot (unsigned char x, unsigned char y);
void LCD_Rectangle (unsigned char x,unsigned char y,unsigned char a,unsigned char b);
/*******************************************************************/
/******************MAIN PROGRAM************************************/

void main(void)
{
P1 = 0x00;
P3 = 0x00;

LCD_init();
LCD_test();

}
/******************************************************************/

void LCD_init(void)
{

LCD_Select_Side(LEFT);
LCD_Command_Write(DISPLAY_ON);
LCD_Command_Write(DISPLAY_START_LINE);
LCD_Command_Write(DISPLAY_PAGE_SET);
LCD_Command_Write(DISPLAY_COLUMN_SET);

LCD_Select_Side(RIGHT);
LCD_Command_Write(DISPLAY_ON);
LCD_Command_Write(DISPLAY_START_LINE);
LCD_Command_Write(DISPLAY_PAGE_SET);
LCD_Command_Write(DISPLAY_COLUMN_SET);

LCD_Start_Line(0);
LCD_Set_Address(0,0);
}
/*******************************************************************/
void LCD_test(void)
{
LCD_clear_scrn();
LCD_Set_Address(4,LINE2);
LCD_Putstr("P1 12.500V 05.000A");
LCD_Set_Address(4,LINE3);
LCD_Putstr("cv cc ");
LCD_Set_Address(4,LINE4);
LCD_Putstr("P2 12.500 05.000A");
LCD_Set_Address(4,LINE5);
LCD_Putstr("cv cc ");
LCD_Set_Address(4,LINE6);
LCD_Putstr("output on/off ");
LCD_Set_Address(4,LINE7);
LCD_Putstr("Remote ovp/ocp");
LCD_Rectangle(0,0,64,128);
}
/*******************************************************************/
void LCD_Putstr(unsigned char *ptr)
{
while(*ptr)
{
LCD_Write_Char(*ptr);
ptr++;
}
}

/*******************************************************************/
void LCD_clear_scrn(void)
{
unsigned char x, y;

LCD_CS0 = 1;
for(y =0; y <8; y++)
{
LCD_Page_Set(0);
LCD_Column_Set(y);
for(x =0; x< 64; x++)LCD_Data_Write(0x00);
}
LCD_CS0 = 0;
LCD_CS1 = 1;
for(y =0; y <8; y++)
{
LCD_Page_Set(0);
LCD_Column_Set(y);
for(x =0; x< 64; x++)LCD_Data_Write(0x00);
}
LCD_CS1 = 0;
}

/******************************************************************/
void LCD_Write_Char(unsigned char c)
{
unsigned char i = 0, x;
unsigned char Data;
if(CursorX >128)
{
CursorX =0;
CursorY++;
if(CursorY ==8)CursorY =0;
}
if(CursorX <64)
{
LCD_CS0 = 1;
x =CursorX;

}
else
{
LCD_CS1 = 1;
x =CursorX - 64;
}
LCD_Page_Set(x); /* After removing this only half part of LCD Displayed the Text*/
LCD_Column_Set(CursorY); /* After removing this only half part of LCD Displayed the Text*/
do{
Data =Font[((c - 0x20) * 5)+i ];
LCD_Data_Write(Data);
i++;
CursorX++;
if(CursorX ==64)
{
LCD_CS0 = 0;
LCD_CS1 = 1;
}
else if(CursorX ==128)
{
LCD_CS0 = 1;
LCD_CS1 = 0;
CursorX =0;
CursorY++;
if(CursorY ==8)CursorY =0;
}
if(CursorX <64)x =CursorX;
else x =CursorX - 64;
LCD_Page_Set(x); /* After removing this only half part of LCD Displayed the Text*/
LCD_Column_Set(CursorY); /* After removing this only half part of LCD Displayed the Text*/
}
while(i<5);
CursorX++;
if(CursorX ==128)CursorX =0;
else LCD_Data_Write(0x00);
LCD_CS0 = 0;
LCD_CS1 = 0;
LCD_Start_Line(0);
}
/*****************************************************************/
void LCD_Start_Line(unsigned char start)
{

LCD_Select_Side(LEFT);
LCD_Command_Write(DISPLAY_START_LINE | (start));

LCD_Select_Side(RIGHT);
LCD_Command_Write(DISPLAY_START_LINE | (start));

}
/******************************************************************/
void LCD_Data_Write(unsigned char Data)
{
LCD_Wait_Busy();
LCD_RS = 1;
LCD_RW = 0;
P1 = Data;
LCD_E = 1;
Delay(20);
LCD_E = 0;

}
/******************************************************************/
void LCD_Command_Write(unsigned char Command )
{
LCD_Wait_Busy();
LCD_RS = 0;
LCD_RW =0;
P1 = Command;
LCD_E =1;
Delay(20);
LCD_E =0;

}
/*************Read Data From LCD************************************/
unsigned char LCD_Data_Read(void)
{
LCD_Wait_Busy();
P1 = 0x00;
LCD_RS =1; //Data Mode
LCD_RW =1; // Read Mode
LCD_E =1;
Delay(20);
LCD_E =0;
Delay(20);
return P1;
}
/******************************************************************/
void LCD_Wait_Busy(void)
{
P1 = 0x00;
LCD_RS =0; //Instruction Mode
LCD_RW =1; // Read Mode
LCD_E =1;
Delay(20);
LCD_E =0;
while(P1 & 0x7F ==BUSY); //test the Busy Bit

}
/******************************************************************/
void LCD_Set_Address(unsigned char x,unsigned char y)
{
LCD_Page_Set(x);
LCD_Column_Set(y);
}
/*****************From left to right(0 : 63)**********************/

void LCD_Page_Set(unsigned char xAddr)
{
LCD_Select_Side(LEFT);
LCD_Command_Write(DISPLAY_PAGE_SET | xAddr);
LCD_Select_Side(RIGHT);
LCD_Command_Write(DISPLAY_PAGE_SET | xAddr);

}
/****************From top to bottom(0 : 7)************************/
void LCD_Column_Set(unsigned char yAddr)
{
LCD_Select_Side(LEFT);
LCD_Command_Write(DISPLAY_COLUMN_SET | yAddr);
LCD_Select_Side(RIGHT);
LCD_Command_Write(DISPLAY_COLUMN_SET | yAddr);
}
/*******************************************************************/
void Delay(unsigned int wait)
{
while(wait!=0)
{
wait--;
}
}
/******************************************************************/

void LCD_Select_Side(unsigned char LcdSide)
{
if(LcdSide ==LEFT)
{
//Switch to left Side
LCD_E =0;
LCD_RS =0;
LCD_CS0 =1;
LCD_CS1 =0;
LCD_RW =1;
LCD_Command_Write(DISPLAY_COLUMN_SET);
}
else
{
//Switch to rigth Side
LCD_E =0;
LCD_RS =0;
LCD_CS0 =0;
LCD_CS1 =1;
LCD_RW =1;
LCD_Command_Write(DISPLAY_COLUMN_SET);
}
}
/******************************************************************/
void LCD_Set_Dot(unsigned char x, unsigned char y)
{
unsigned char Temp;
if(x <64)
{
LCD_CS0 =1;
LCD_Page_Set(x);
LCD_Column_Set(y/8);
Temp = LCD_Data_Read();
Temp = LCD_Data_Read();
LCD_Page_Set(x);
LCD_Data_Write(Temp | (1<<(y%8)));
LCD_CS0 =0;
}
else
{
LCD_CS1 =1;
LCD_Page_Set(x -64);
LCD_Column_Set(y/8);
Temp = LCD_Data_Read();
Temp = LCD_Data_Read();
LCD_Page_Set(x -64);
LCD_Data_Write(Temp | (1<<(y%8)));
LCD_CS0 =0;
}
LCD_Start_Line(0);
}
/******************************************************************/
void LCD_Rectangle(unsigned char x,unsigned char y,unsigned char a,unsigned char b)
{
unsigned char j;
for(j=0; j<a; j++)
{
LCD_Set_Dot(x, y + j);
LCD_Set_Dot(x + b - 1, y + j);
}
for(j=0; j<b; j++)
{
LCD_Set_Dot(x + j, y );
LCD_Set_Dot(x + j, y + a - 1);
}
}
/********************************************************************/ [/code]


Top
 Profile  
 
PostPosted: Thu Jan 20, 2005 7:30 
Offline

Joined: Mon Jan 03, 2005 7:04
Posts: 4
Location: South Korea
Anoop wrote:
Henri wrote:
How are you handling the CS1 and CS2 pins in your code ? Normally you should only have one side of the display enabled at a time as the display is made of two 64x64 parts and with the CS signals you select which one is currently used

Pls check this code As I marked note in LCD_Write_Char Subroutine As(LCD_Page_Set() & LCD_Column_Set() ) After removing this 2 subroutines only half of display glow otherwise no Display at all. & Data sheet in pdf As:-

http://www.dataimage.com.tw/en/product/ ... AYA-01.pdf

thanks in advance Henri !!
Anoop

/**************Start********************************/
#include <stdio.h>
#include <io320.h> // SFR declarations
#include <Font.h>

#define DISPLAY_ON 0x3F
#define DISPLAY_OFF 0x3E
#define DISPLAY_START_LINE 0xC0
#define DISPLAY_PAGE_SET 0xB8
#define DISPLAY_COLUMN_SET 0x40

sbit LCD_E = P3^0; //pin for Display Enable
sbit LCD_RS =P3^1; //pin for register select
sbit LCD_CS0 =P3^2; //pin for Controller1 Chip select
sbit LCD_CS1 =P3^3; //pin for Controller2 Chip select
sbit LCD_RW =P3^4; //pin for read/write


#define RIGHT 0
#define LEFT 1
#define BUSY 0x80
unsigned char CursorX, CursorY;

#define LINE1 0
#define LINE2 1
#define LINE3 2
#define LINE4 3
#define LINE5 4
#define LINE6 5
#define LINE7 6
#define LINE8 7


/****************SUB ROUTIENS**************************************/
void Delay(unsigned int wait);
void LCD_init(void);
void LCD_clear_scrn(void);
void LCD_test(void);
void LCD_Putstr(unsigned char *ptr);
void LCD_Page_Set(unsigned char xAddr);
void LCD_Column_Set(unsigned char yAddr);
void LCD_Data_Write(unsigned char Data);
void LCD_Start_Line(unsigned char start);
void LCD_Command_Write(unsigned char command);
void LCD_Write_Char(unsigned char c);
void LCD_Set_Address(unsigned char x,unsigned char y);
unsigned char LCD_Data_Read(void);
void LCD_Select_Side(unsigned char LcdSide);
void LCD_Wait_Busy(void);
void LCD_Set_Dot (unsigned char x, unsigned char y);
void LCD_Rectangle (unsigned char x,unsigned char y,unsigned char a,unsigned char b);
/*******************************************************************/
/******************MAIN PROGRAM************************************/

void main(void)
{
P1 = 0x00;
P3 = 0x00;

LCD_init();
LCD_test();

}
/******************************************************************/

void LCD_init(void)
{

LCD_Select_Side(LEFT);
LCD_Command_Write(DISPLAY_ON);
LCD_Command_Write(DISPLAY_START_LINE);
LCD_Command_Write(DISPLAY_PAGE_SET);
LCD_Command_Write(DISPLAY_COLUMN_SET);

LCD_Select_Side(RIGHT);
LCD_Command_Write(DISPLAY_ON);
LCD_Command_Write(DISPLAY_START_LINE);
LCD_Command_Write(DISPLAY_PAGE_SET);
LCD_Command_Write(DISPLAY_COLUMN_SET);

LCD_Start_Line(0);
LCD_Set_Address(0,0);
}
/*******************************************************************/
void LCD_test(void)
{
LCD_clear_scrn();
LCD_Set_Address(4,LINE2);
LCD_Putstr("P1 12.500V 05.000A");
LCD_Set_Address(4,LINE3);
LCD_Putstr("cv cc ");
LCD_Set_Address(4,LINE4);
LCD_Putstr("P2 12.500 05.000A");
LCD_Set_Address(4,LINE5);
LCD_Putstr("cv cc ");
LCD_Set_Address(4,LINE6);
LCD_Putstr("output on/off ");
LCD_Set_Address(4,LINE7);
LCD_Putstr("Remote ovp/ocp");
LCD_Rectangle(0,0,64,128);
}
/*******************************************************************/
void LCD_Putstr(unsigned char *ptr)
{
while(*ptr)
{
LCD_Write_Char(*ptr);
ptr++;
}
}

/*******************************************************************/
void LCD_clear_scrn(void)
{
unsigned char x, y;

LCD_CS0 = 1;
for(y =0; y <8; y++)
{
LCD_Page_Set(0);
LCD_Column_Set(y);
for(x =0; x< 64; x++)LCD_Data_Write(0x00);
}
LCD_CS0 = 0;
LCD_CS1 = 1;
for(y =0; y <8; y++)
{
LCD_Page_Set(0);
LCD_Column_Set(y);
for(x =0; x< 64; x++)LCD_Data_Write(0x00);
}
LCD_CS1 = 0;
}

/******************************************************************/
void LCD_Write_Char(unsigned char c)
{
unsigned char i = 0, x;
unsigned char Data;
if(CursorX >128)
{
CursorX =0;
CursorY++;
if(CursorY ==8)CursorY =0;
}
if(CursorX <64)
{
LCD_CS0 = 1;
x =CursorX;

}
else
{
LCD_CS1 = 1;
x =CursorX - 64;
}
LCD_Page_Set(x); /* After removing this only half part of LCD Displayed the Text*/
LCD_Column_Set(CursorY); /* After removing this only half part of LCD Displayed the Text*/
do{
Data =Font[((c - 0x20) * 5)+i ];
LCD_Data_Write(Data);
i++;
CursorX++;
if(CursorX ==64)
{
LCD_CS0 = 0;
LCD_CS1 = 1;
}
else if(CursorX ==128)
{
LCD_CS0 = 1;
LCD_CS1 = 0;
CursorX =0;
CursorY++;
if(CursorY ==8)CursorY =0;
}
if(CursorX <64)x =CursorX;
else x =CursorX - 64;
LCD_Page_Set(x); /* After removing this only half part of LCD Displayed the Text*/
LCD_Column_Set(CursorY); /* After removing this only half part of LCD Displayed the Text*/
}
while(i<5);
CursorX++;
if(CursorX ==128)CursorX =0;
else LCD_Data_Write(0x00);
LCD_CS0 = 0;
LCD_CS1 = 0;
LCD_Start_Line(0);
}
/*****************************************************************/
void LCD_Start_Line(unsigned char start)
{

LCD_Select_Side(LEFT);
LCD_Command_Write(DISPLAY_START_LINE | (start));

LCD_Select_Side(RIGHT);
LCD_Command_Write(DISPLAY_START_LINE | (start));

}
/******************************************************************/
void LCD_Data_Write(unsigned char Data)
{
LCD_Wait_Busy();
LCD_RS = 1;
LCD_RW = 0;
P1 = Data;
LCD_E = 1;
Delay(20);
LCD_E = 0;

}
/******************************************************************/
void LCD_Command_Write(unsigned char Command )
{
LCD_Wait_Busy();
LCD_RS = 0;
LCD_RW =0;
P1 = Command;
LCD_E =1;
Delay(20);
LCD_E =0;

}
/*************Read Data From LCD************************************/
unsigned char LCD_Data_Read(void)
{
LCD_Wait_Busy();
P1 = 0x00;
LCD_RS =1; //Data Mode
LCD_RW =1; // Read Mode
LCD_E =1;
Delay(20);
LCD_E =0;
Delay(20);
return P1;
}
/******************************************************************/
void LCD_Wait_Busy(void)
{
P1 = 0x00;
LCD_RS =0; //Instruction Mode
LCD_RW =1; // Read Mode
LCD_E =1;
Delay(20);
LCD_E =0;
while(P1 & 0x7F ==BUSY); //test the Busy Bit

}
/******************************************************************/
void LCD_Set_Address(unsigned char x,unsigned char y)
{
LCD_Page_Set(x);
LCD_Column_Set(y);
}
/*****************From left to right(0 : 63)**********************/

void LCD_Page_Set(unsigned char xAddr)
{
LCD_Select_Side(LEFT);
LCD_Command_Write(DISPLAY_PAGE_SET | xAddr);
LCD_Select_Side(RIGHT);
LCD_Command_Write(DISPLAY_PAGE_SET | xAddr);

}
/****************From top to bottom(0 : 7)************************/
void LCD_Column_Set(unsigned char yAddr)
{
LCD_Select_Side(LEFT);
LCD_Command_Write(DISPLAY_COLUMN_SET | yAddr);
LCD_Select_Side(RIGHT);
LCD_Command_Write(DISPLAY_COLUMN_SET | yAddr);
}
/*******************************************************************/
void Delay(unsigned int wait)
{
while(wait!=0)
{
wait--;
}
}
/******************************************************************/

void LCD_Select_Side(unsigned char LcdSide)
{
if(LcdSide ==LEFT)
{
//Switch to left Side
LCD_E =0;
LCD_RS =0;
LCD_CS0 =1;
LCD_CS1 =0;
LCD_RW =1;
LCD_Command_Write(DISPLAY_COLUMN_SET);
}
else
{
//Switch to rigth Side
LCD_E =0;
LCD_RS =0;
LCD_CS0 =0;
LCD_CS1 =1;
LCD_RW =1;
LCD_Command_Write(DISPLAY_COLUMN_SET);
}
}
/******************************************************************/
void LCD_Set_Dot(unsigned char x, unsigned char y)
{
unsigned char Temp;
if(x <64)
{
LCD_CS0 =1;
LCD_Page_Set(x);
LCD_Column_Set(y/8);
Temp = LCD_Data_Read();
Temp = LCD_Data_Read();
LCD_Page_Set(x);
LCD_Data_Write(Temp | (1<<(y%8)));
LCD_CS0 =0;
}
else
{
LCD_CS1 =1;
LCD_Page_Set(x -64);
LCD_Column_Set(y/8);
Temp = LCD_Data_Read();
Temp = LCD_Data_Read();
LCD_Page_Set(x -64);
LCD_Data_Write(Temp | (1<<(y%8)));
LCD_CS0 =0;
}
LCD_Start_Line(0);
}
/******************************************************************/
void LCD_Rectangle(unsigned char x,unsigned char y,unsigned char a,unsigned char b)
{
unsigned char j;
for(j=0; j<a; j++)
{
LCD_Set_Dot(x, y + j);
LCD_Set_Dot(x + b - 1, y + j);
}
for(j=0; j<b; j++)
{
LCD_Set_Dot(x + j, y );
LCD_Set_Dot(x + j, y + a - 1);
}
}
/********************************************************************/ [/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 02, 2005 16:56 
Offline

Joined: Wed Mar 02, 2005 14:51
Posts: 2
Hello Anoop Tiwari,

I wrote a programm for an equal display by myself.
To display your data correctly, you should (try to) manipulate the LCD_CS-variables in the LCD_Column_Set-Routine only.
So if you want to change the CS-value, call your LCD_Column_Set-routine :wink:
Execute the LCD_Column_Set- and LCD_Page_Set-routines every time you write a column/byte on the display. This might slow down your programm, but it avoids displaying errors.

Your routines could look like this:

void LCD_Column_Set(unsigned char yAddr) //yAddr=0..127
{
LCD_CS0=(yAddr<64?LEFT:RIGHT);
LCD_CS1=LCD_CS0?0:1;
LCD_E = 1;
LCD_RS =0;
LCD_RW =1;
P1 = DISPLAY_COLUMN_SET | ((y<64) ? y : (y-64));
LCD_E = 0;
}

void LCD_Page_Set(unsigned char xAddr) //xAddr=0..7
{
LCD_E = 1;
LCD_RS =0;
P1 = DISPLAY_PAGE_SET | xAddr;
_nop_();
_nop_();
_nop_();
_nop_();
LCD_E = 0;
}

void LCD_Write_Char(unsigned char c)
{
...
if(CursorY>123){
CursorY=0;
CursorX=(CursorX+1)%8;
}
...
do{
LCD_Column_Set(CursorY);
LCD_Page_Set(CursorX);
Data =Font[((c - 0x20) * 5)+i ];
LCD_Data_Write(Data);
i++;
CursorY++;
}
while(i<5);

...
}

The LCD_Select_Side-routine is unnecessary/obsolete.
I hope this could help to solve your problem...

errol_


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 02, 2005 17:18 
Offline

Joined: Wed Mar 02, 2005 14:51
Posts: 2
I exchanged the x- and y-cursor variables, because the display is organized like this:

Image

regards
errol_


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: Google [Bot] and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group