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.pdfthanks 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]