Maverickmax
Advanced Member level 1
lcd module datasheet
Hi
I am not sure that I have written code in correct ways because I am slightly confused with E1 and E2. I believe they are used to transmit enable signal for master and slave respectively. Bascially I would to print a line on the top and left corner of the lcd. Please correct me if I have made a mistake in my code
Thank you in advance
MM
P.S If you help me to solve this matter, I will reward you whopping 150 points
Hi
I am not sure that I have written code in correct ways because I am slightly confused with E1 and E2. I believe they are used to transmit enable signal for master and slave respectively. Bascially I would to print a line on the top and left corner of the lcd. Please correct me if I have made a mistake in my code
Thank you in advance
MM
P.S If you help me to solve this matter, I will reward you whopping 150 points
Code:
// Function Prototypes
void Display(int Status);
void Display_Start_Line(int Row);
void Static_Drive(int Drive);
void Column_Address(int Address);
void Page(int Number);
void DutyCycle(int Switch);
void ADC_Select(int Output);
void End();
void Write_Display(int Line);
void Delay();
void Delay()
{
int i;
for(i=0; i<100; i++);
}
void Display(int Status)
{
static int DATA;
DATA=0x5E | Status;
PORTB=DATA;
PORTE=0x00; // A0 - 0 Bit
// R/W - 1 Bit
// E2 - 2 Bit (Slave)
// E1 - 3 Bit (Master)
PORTE=0x04;
Delay();
PORTE=0x00;
PORTB=0x00;
}
void Display_Start_Line(int Row)
{
static int DATA;
DATA=0xCE | Row;
PORTB=DATA;
PORTE=0x00; // A0 - 0 Bit
// R/W - 1 Bit
// E2 - 2 Bit (Slave)
// E1 - 3 Bit (Master)
PORTE=0x04;
Delay();
PORTE=0x00;
PORTB=0x00;
}
void Static_Drive(int Drive)
{
static int DATA;
DATA=0xAE | Drive;
PORTB=DATA;
PORTE=0x00; // A0 - 0 Bit
// R/W - 1 Bit
// E2 - 2 Bit (Slave)
// E1 - 3 Bit (Master)
PORTE=0x04;
Delay();
PORTE=0x00;
PORTB=0x00;
}
void Column_Address(int Address)
{
static int DATA;
DATA= Address;
PORTB=DATA;
PORTE=0x00; // A0 - 0 Bit
// R/W - 1 Bit
// E2 - 2 Bit (Slave)
// E1 - 3 Bit (Master)
PORTE=0x04;
Delay();
PORTE=0x00;
PORTB=0x00;
}
void Page(int Number)
{
static int DATA;
DATA=0xB8 | Number;
PORTB=DATA;
PORTE=0x00; // A0 - 0 Bit
// R/W - 1 Bit
// E2 - 2 Bit (Slave)
// E1 - 3 Bit (Master)
PORTE=0x04;
Delay();
PORTE=0x00;
PORTB=0x00;
}
void DutyCycle(int Switch)
{
static int DATA;
DATA=0xA8 | Switch;
PORTB=DATA;
PORTE=0x00; // A0 - 0 Bit
// R/W - 1 Bit
// E2 - 2 Bit (Slave)
// E1 - 3 Bit (Master)
PORTE=0x04;
Delay();
PORTE=0x00;
PORTB=0x00;
}
void ADC_Select(int Output)
{
static int DATA;
DATA=0xA0 | Output;
PORTB=DATA;
PORTE=0x00; // A0 - 0 Bit
// R/W - 1 Bit
// E2 - 2 Bit (Slave)
// E1 - 3 Bit (Master)
PORTE=0x04;
Delay();
PORTE=0x00;
PORTB=0x00;
}
void End()
{
PORTB=0xEE;
PORTE=0x00; // A0 - 0 Bit
// R/W - 1 Bit
// E2 - 2 Bit (Slave)
// E1 - 3 Bit (Master)
PORTE=0x04;
Delay();
PORTE=0x00;
PORTB=0x00;
}
void Write_Display(int Line)
{
static int DATA;
DATA=Line;
PORTB=DATA;
PORTE=0x01; // A0 - 0 Bit
// R/W - 1 Bit
// E2 - 2 Bit (Slave)
// E1 - 3 Bit (Master)
PORTE=0x05;
Delay();
PORTE=0x00;
PORTB=0x00;
}
int main (void)
{
//unsigned char counter;
DDRB = 0xFF;
DDRE = 0xFF;
PORTB = 0x00;
PORTE = 0x00;
Display(0x01);
Display_Start_Line(0x00);
Static_Drive(0x00);
Column_Address(0x00);
Page(0x03);
DutyCycle(0x01);
ADC_Select(0x00);
End();
Write_Display(0xFF);
while(1)
{
return 1;
}
}