I am using CFAH1604A-NYG-JP connected with LPC2106 microcontroller. My cable connections are as follows:
Pin# Symbol Description
1 Vss GND
2 Vdd +4.5V
3 Vo GND
4 RS P0.0
5 R/W P0.2
6 E P0.4
7 DB0 P0.6
8 DB1 P0.8
9 DB2 P0.10
10 DB3 P0.12
11 DB4 P0.14
12 DB5 P0.16
13 DB6 P0.18
14 DB7 P0.20
15 A +4.5V
16 K GND
After connection as described, all I see is LCD backlight and 1st and 3rd row with black boxes. The complete software code is below. Somehow there is no effect of any initialization instructions. To debug, I have LED connected to E pin(P0.4). I also have two extra debug LED connected at pin P0.5(return from status-busy indication) and P0.7(status-busy indication). After execution, I observe that the program execution indicates proper returns from the busy state. This means that the module is operating properly and is not losing instructions because of busy state. Still there is no effect on display and all I see is the same display of black boxes in 1st and 3rd row. Even my function set instruction is not accepted as it should be enabling 2 line display. In other words at the end of my function set instruction, I should see black boxes in 2nd and 4th line as well.
Any clues where is the problem? Maybe broken LCDs?(I have 2 LCD modules... both have same display).
Thanks in advance....
Pin# Symbol Description
1 Vss GND
2 Vdd +4.5V
3 Vo GND
4 RS P0.0
5 R/W P0.2
6 E P0.4
7 DB0 P0.6
8 DB1 P0.8
9 DB2 P0.10
10 DB3 P0.12
11 DB4 P0.14
12 DB5 P0.16
13 DB6 P0.18
14 DB7 P0.20
15 A +4.5V
16 K GND
After connection as described, all I see is LCD backlight and 1st and 3rd row with black boxes. The complete software code is below. Somehow there is no effect of any initialization instructions. To debug, I have LED connected to E pin(P0.4). I also have two extra debug LED connected at pin P0.5(return from status-busy indication) and P0.7(status-busy indication). After execution, I observe that the program execution indicates proper returns from the busy state. This means that the module is operating properly and is not losing instructions because of busy state. Still there is no effect on display and all I see is the same display of black boxes in 1st and 3rd row. Even my function set instruction is not accepted as it should be enabling 2 line display. In other words at the end of my function set instruction, I should see black boxes in 2nd and 4th line as well.
Any clues where is the problem? Maybe broken LCDs?(I have 2 LCD modules... both have same display).
Code:
/********************************************************************
Module: sw2.c
Version Date Initials Description
0.0.1 02/05/07 DHC First version inherited from
sw.c
0.0.2 02/07/07 DHC Incremental & Decremental LEDs
functioality added
0.0.3 02/27/07 DHC Modified for LCD Display
********************************************************************/
//LPC2100 definitions
#include "LPC2100_addrs.h"
//write address to register macro
#define REG(addr) (*(volatile unsigned long *) (addr))
//local functions
void lcd_init(void);
void startup_display(void);
void wait1(void);
void checkbusy(void);
void wait2(void);
void lcd_disp(void);
void busycheck(void);
//program main
int main(void)
{
unsigned long i;
//Initialization
//SET DIRECTIONS OF GPIO PORT
REG(GPIO_IODIR) = 0x00155555;
wait2();
REG(GPIO_IOCLR) = 0x00155555;
wait2();
//REG(GPIO_IOSET) = 0x00155545;
lcd_init();
lcd_disp();
while(1);
}
/*******************************************************************
Function Prototypes
*******************************************************************/
void lcd_init(void)
{
unsigned long j,i;
for(i=0;i<40;i++)
{
wait2();
}
//BF CANNOT BE CHECKED BEFORE THIS INSTRUCTION I
REG(GPIO_IOCLR) = 0x00000005; //RS = 0, R/W = 0
REG(GPIO_IOCLR) = 0x00155510; //DB = 0x00
REG(GPIO_IOSET) = 0x00015000; //DB = 0x38
wait1();
for(i=0;i<10;i++)
{
wait2();
}
//BF CANNOT BE CHECKED BEFORE THIS INSTRUCTION II
REG(GPIO_IOCLR) = 0x00000005; //RS = 0, R/W = 0
REG(GPIO_IOCLR) = 0x00155510; //DB = 0x00
REG(GPIO_IOSET) = 0x00015000; //DB = 0x38
wait1();
for(i=0;i<10;i++)
{
wait2();
}
//BF CANNOT BE CHECKED BEFORE THIS INSTRUCTION III
REG(GPIO_IOCLR) = 0x00000005; //RS = 0, R/W = 0
REG(GPIO_IOCLR) = 0x00155510; //DB = 0x00
REG(GPIO_IOSET) = 0x00015000; //DB = 0x38
wait1();
wait2();
for(i=0;i<10;i++)
{
wait2();
}
busycheck();
REG(GPIO_IOSET) = 0x00000020;
wait2();
wait2();
REG(GPIO_IODIR) = 0x00155555;
wait2();
wait2();
//FUNCTION SET
REG(GPIO_IOCLR) = 0x00000005; //RS = 0, R/W = 0
REG(GPIO_IOCLR) = 0x00155510; //DB = 0x00
REG(GPIO_IOSET) = 0x00015000; //DB = 0x38
wait1();
wait2();
for(i=0;i<10;i++)
{
wait2();
}
busycheck();
REG(GPIO_IOSET) = 0x00000020;
wait2();
wait2();
REG(GPIO_IODIR) = 0x00155555;
wait2();
wait2();
//DISPLAY ON/OFF CONTROL
REG(GPIO_IOCLR) = 0x00155515; //DB = 0x00, RS = 0, R/W = 0
wait2();
wait2();
REG(GPIO_IOSET) = 0x00001400; //DB = 0x0C
//REG(GPIO_IOSET) = 0x00001540; //DB = 0x0E
//REG(GPIO_IOSET) = 0x00001000; //Display = OFF
wait1();
wait2();
for(i=0;i<10;i++)
{
wait2();
}
busycheck();
REG(GPIO_IOSET) = 0x00000020;
wait2();
REG(GPIO_IODIR) = 0x00155555;
wait2();
//DISPLAY CLEAR
REG(GPIO_IOCLR) = 0x00155510; //DB = 0x00
REG(GPIO_IOCLR) = 0x00000005; //RS = 0, R/W = 0
REG(GPIO_IOSET) = 0x00000040; //DB = 0x01
wait2();
wait1();
wait2();
for(i=0;i<10;i++)
{
wait2();
}
busycheck();
REG(GPIO_IOSET) = 0x00000020;
wait2();
REG(GPIO_IODIR) = 0x00155555;
wait2();
//ENTRY MODE SET
REG(GPIO_IOCLR) = 0x00155510; //DB = 0x00
REG(GPIO_IOCLR) = 0x00000005; //RS = 0, R/W = 0
REG(GPIO_IOSET) = 0x00000500; //DB = 0x06
wait2();
wait1();
wait2();
for(i=0;i<10;i++)
{
wait2();
}
busycheck();
REG(GPIO_IOSET) = 0x00000020;
wait2();
REG(GPIO_IODIR) = 0x00155555;
wait2();
//while(1);
}
void wait1(void)
{
unsigned long j;
REG(GPIO_IOCLR) = 0x00000010; //E = 0
for(j=0;j<250000;j++);
REG(GPIO_IOSET) = 0x00000010; //E = 1
for(j=0;j<500000;j++);
REG(GPIO_IOCLR) = 0x00000010; //E = 0
for(j=0;j<250000;j++);
}
void wait2(void)
{
unsigned long j;
for(j=0;j<250000;j++); //250 ~ 1 msec
}
void lcd_disp(void)
{
//Display characters
unsigned long i;
busycheck();
REG(GPIO_IOSET) = 0x00000020;
wait2();
REG(GPIO_IODIR) = 0x00155555;
wait2();
REG(GPIO_IOCLR) = 0x00155514; //DB = 0x00
REG(GPIO_IOSET) = 0x00100000; //Set DDRAM Address
wait2();
wait1();
wait2();
//busycheck();
REG(GPIO_IOCLR) = 0x00155514; //DB = 0x00
REG(GPIO_IOSET) = 0x00000001; //RS = 1, R/W = 0
REG(GPIO_IOSET) = 0x00041000; //H
wait2();
wait1();
wait2();
for(i=0;i<10;i++)
{
wait2();
}
busycheck();
REG(GPIO_IOSET) = 0x00000020;
wait2();
REG(GPIO_IODIR) = 0x00155555;
wait2();
REG(GPIO_IOCLR) = 0x00155514; //DB = 0x00
REG(GPIO_IOSET) = 0x00000001; //RS = 1, R/W = 0
REG(GPIO_IOSET) = 0x00041040; //I
wait2();
wait1();
wait2();
for(i=0;i<10;i++)
{
wait2();
}
busycheck();
REG(GPIO_IOSET) = 0x00000020;
wait2();
REG(GPIO_IODIR) = 0x00155555;
wait2();
REG(GPIO_IOCLR) = 0x00155510; //DB = 0x00
REG(GPIO_IOCLR) = 0x00000005; //RS = 0, R/W = 0
REG(GPIO_IOSET) = 0x00000100; // Return home
wait2();
wait2();
wait2();
for(i=0;i<10;i++)
{
wait2();
}
busycheck();
REG(GPIO_IOSET) = 0x00000020;
wait2();
REG(GPIO_IODIR) = 0x00155555;
wait2();
}
void busycheck(void)
{
unsigned long i;
unsigned short x; //changed to short from char
unsigned long w;
REG(GPIO_IOCLR) = 0x00155540;
for(i=0;i<10;i++)
{
wait2();
}
REG(GPIO_IODIR) = 0x000000E5; //E, RS, R/W => outputs
REG(GPIO_IOCLR) = 0x00000001;
wait2();
REG(GPIO_IOSET) = 0x00000014; //RS =0, R/W = 1, E = 1
wait2();
wait2();
//while(x & 0x00100000 == 0x00100000)
//while(1)
for(i=0;i<10;i++)
{
x = REG(GPIO_IOPIN);
wait2();
wait2();
//if(REG(GPIO_IOPIN) & 1048576 == 1048576)
if(REG(GPIO_IOPIN) & 0x100000 == 0x100000)
//while(REG(GPIO_IOPIN) & 1048576)
{
REG(GPIO_IOSET) = 0x00000080;
//wait1();
wait2();
wait2();
}
else
{
break;
}
}
REG(GPIO_IOCLR) = 0x00000080;
wait2();
}
Thanks in advance....
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.