EmbeddedRelated.com
Forums

LCD with LPC2138

Started by oldulik April 1, 2007
Hello to all, I hope, somebody here will help me. I have a problem
with initializing LCD displej connecting to LPC2138. I have a display
from Everboucket, MC16021E8 SYL.
After connecting 5V, only black squares, after uploading the
initialization sequence, its same. I think, that there isnt HW
problem, but its SW, but I dont know, where Im doing mistake. Here is
my initialization sequence. Thank to all idea.
Oldriska

#include

void InitDisplay(void);
void LCDSendCommand(unsigned long a);
unsigned long data;

void DelayS (unsigned long a)
{ while (--a!=0); } //jednotka je 1us

void Enable(void)
{
IOSET0 = 0x00100000; //P0.20 - EN do 1
DelayS(10);
IOCLR0 = 0x00100000; //P0.20 - EN do 0
}

unsigned long data;

void main(void)
{
InitDisplay();

}

void InitDisplay(void)
{
IODIR0 = 0x0030F000;
IOCLR0 = 0x0030F000;

DelayS(15000); //cekani 15ms na vnitrni reset

IOSET0 = 0x00003000; //8bit interface
Enable();
DelayS(4100); //min 4.1ms

IOSET0 = 0x00003000; //8bit interface
Enable();
DelayS(100); //100us

IOSET0 = 0x00003000; //8bit interface
Enable();
DelayS(40); //40us

IOSET0 = 0x00002000; //4bit inteface
Enable();
DelayS(40); //40us

LCDSendCommand(0x00002800); // 4bitovy mod, 2 radky, 5x7 puntiku
//function set
DelayS(40);

LCDSendCommand(0x00000800); //display off
DelayS(40);

LCDSendCommand(0x00000100); // clear display
DelayS(1600);

LCDSendCommand(0x00000600); // entry mode set
DelayS(40);

}

void LCDSendCommand(unsigned long a)
{
IOCLR0= 0x01000000; //24,set RW port to 0

DelayS(2000); //delay for LCD char ~2ms

data = 0xffff0fff | a; //get high 4 bits
IOCLR0 = 0x0000f000; //clear D4-D7
IOSET0 = (IOSET0 | 0x0000f000) & data; //set D4-D7
IOCLR0= 0x00200000; //23,set RS port to 0 ->
display set to comand mode
Enable(); //pulse to set d4-d7 bits
data = (a << 4) & 0x0000f000; //get low 4 bits
IOCLR0= 0x0000f000; //clear D4-D7
IOSET0 = (IOSET0 & 0xffff0fff) | data; //set D4-D7 (only
PORTC4-PORTC7)
IOCLR0= 0x00200000; //set RS port to 0 -> display
set to command mode
Enable(); //pulse to set d4-d7 bits

}

An Engineer's Guide to the LPC2100 Series

A google search for "arm lcd c" gives this site as the 5th hit:
http://www.dreamislife.com/arm/

where there is an excellent LCD driver code example which I very
recently used to make my own driver for an LPC2138.

Blocks on the LCD tell you that you are getting power, but the LCD is
uninitialized. So your analysis is correct; it is a software problem.
You will have to get a volt meter out and make sure that your toggling
the lines you mean to toggle. The ability to use JTAG debugging would
help you greatly, but if you don't have that, you will have to introduce
long delay loops to slow down your code so you can poke around with the
volt meter.

I haven't looked too deeply into your code, but I wonder if your Enable
routine is right. You are only pulsing the enable line for 10uS which
may not be what you want to do. I think you mean to do something like this:
1> disable LCD
2> change the data
3> enable LCD
4> wait for the min hold time

Keep trying! This is an easy and fun exercise!

--Johnny

oldulik wrote:
> Hello to all, I hope, somebody here will help me. I have a problem
> with initializing LCD displej connecting to LPC2138. I have a display
> from Everboucket, MC16021E8 SYL.
> After connecting 5V, only black squares, after uploading the
> initialization sequence, its same. I think, that there isnt HW
> problem, but its SW, but I dont know, where Im doing mistake. Here is
> my initialization sequence. Thank to all idea.
> Oldriska
>
> #include void InitDisplay(void);
> void LCDSendCommand(unsigned long a);
> unsigned long data;
>
> void DelayS (unsigned long a)
> { while (--a!=0); } //jednotka je 1us
>
> void Enable(void)
> {
> IOSET0 = 0x00100000; //P0.20 - EN do 1
> DelayS(10);
> IOCLR0 = 0x00100000; //P0.20 - EN do 0
> }
>
> unsigned long data;
>
> void main(void)
> {
> InitDisplay();
>
> }
>
> void InitDisplay(void)
> {
> IODIR0 = 0x0030F000;
> IOCLR0 = 0x0030F000;
>
> DelayS(15000); //cekani 15ms na vnitrni reset
>
> IOSET0 = 0x00003000; //8bit interface
> Enable();
> DelayS(4100); //min 4.1ms
>
> IOSET0 = 0x00003000; //8bit interface
> Enable();
> DelayS(100); //100us
>
> IOSET0 = 0x00003000; //8bit interface
> Enable();
> DelayS(40); //40us
>
> IOSET0 = 0x00002000; //4bit inteface
> Enable();
> DelayS(40); //40us
>
>
> LCDSendCommand(0x00002800); // 4bitovy mod, 2 radky, 5x7 puntiku
> //function set
> DelayS(40);
>
> LCDSendCommand(0x00000800); //display off
> DelayS(40);
>
> LCDSendCommand(0x00000100); // clear display
> DelayS(1600);
>
> LCDSendCommand(0x00000600); // entry mode set
> DelayS(40);
>
> }
>
> void LCDSendCommand(unsigned long a)
> {
> IOCLR0= 0x01000000; //24,set RW port to 0
>
> DelayS(2000); //delay for LCD char ~2ms
>
> data = 0xffff0fff | a; //get high 4 bits
> IOCLR0 = 0x0000f000; //clear D4-D7
> IOSET0 = (IOSET0 | 0x0000f000) & data; //set D4-D7
> IOCLR0= 0x00200000; //23,set RS port to 0 ->
> display set to comand mode
> Enable(); //pulse to set d4-d7 bits
> data = (a << 4) & 0x0000f000; //get low 4 bits
> IOCLR0= 0x0000f000; //clear D4-D7
> IOSET0 = (IOSET0 & 0xffff0fff) | data; //set D4-D7 (only
> PORTC4-PORTC7)
> IOCLR0= 0x00200000; //set RS port to 0 -> display
> set to command mode
> Enable(); //pulse to set d4-d7 bits
>
> }
>
Check your LCD contrast. I'm not sure which display you're using, but
when you "clear" it, it should be clear... not covered in blocks.
I'm guessing you're using a character display rather than a graphics
display? Anyway, if the contrast is set incorrectly, what you're
describing is what you'd see. Power on the display (without
intialising it), and adjust the contrast until the character blocks
are a light grey colour. Once you've got text/data you can see, you
can tweak it from there. Too low or too high and you won't see squat.
Good luck

--- In l..., "oldulik" wrote:
>
> Hello to all, I hope, somebody here will help me. I have a problem
> with initializing LCD displej connecting to LPC2138. I have a display
> from Everboucket, MC16021E8 SYL.
> After connecting 5V, only black squares, after uploading the
> initialization sequence, its same. I think, that there isnt HW
> problem, but its SW, but I dont know, where Im doing mistake. Here is
> my initialization sequence. Thank to all idea.
> Oldriska
>
> #include void InitDisplay(void);
> void LCDSendCommand(unsigned long a);
> unsigned long data;
>
> void DelayS (unsigned long a)
> { while (--a!=0); } //jednotka je 1us
>
> void Enable(void)
> {
> IOSET0 = 0x00100000; //P0.20 - EN do 1
> DelayS(10);
> IOCLR0 = 0x00100000; //P0.20 - EN do 0
> }
>
> unsigned long data;
>
> void main(void)
> {
> InitDisplay();
>
> }
>
> void InitDisplay(void)
> {
> IODIR0 = 0x0030F000;
> IOCLR0 = 0x0030F000;
>
> DelayS(15000); //cekani 15ms na vnitrni reset
>
> IOSET0 = 0x00003000; //8bit interface
> Enable();
> DelayS(4100); //min 4.1ms
>
> IOSET0 = 0x00003000; //8bit interface
> Enable();
> DelayS(100); //100us
>
> IOSET0 = 0x00003000; //8bit interface
> Enable();
> DelayS(40); //40us
>
> IOSET0 = 0x00002000; //4bit inteface
> Enable();
> DelayS(40); //40us
>
>
> LCDSendCommand(0x00002800); // 4bitovy mod, 2 radky, 5x7 puntiku
> //function set
> DelayS(40);
>
> LCDSendCommand(0x00000800); //display off
> DelayS(40);
>
> LCDSendCommand(0x00000100); // clear display
> DelayS(1600);
>
> LCDSendCommand(0x00000600); // entry mode set
> DelayS(40);
>
> }
>
> void LCDSendCommand(unsigned long a)
> {
> IOCLR0= 0x01000000; //24,set RW port to 0
>
> DelayS(2000); //delay for LCD char ~2ms
>
> data = 0xffff0fff | a; //get high 4 bits
> IOCLR0 = 0x0000f000; //clear D4-D7
> IOSET0 = (IOSET0 | 0x0000f000) & data; //set D4-D7
> IOCLR0= 0x00200000; //23,set RS port to 0 ->
> display set to comand mode
> Enable(); //pulse to set d4-d7 bits
> data = (a << 4) & 0x0000f000; //get low 4 bits
> IOCLR0= 0x0000f000; //clear D4-D7
> IOSET0 = (IOSET0 & 0xffff0fff) | data; //set D4-D7 (only
> PORTC4-PORTC7)
> IOCLR0= 0x00200000; //set RS port to 0 -> display
> set to command mode
> Enable(); //pulse to set d4-d7 bits
>
> }
>
Hi,

If all the characters re displayed as blocks, then the LCD has not been
initialised properly.

Cheers,

Peter.

Darcy Williams wrote:
> Check your LCD contrast. I'm not sure which display you're using, but
> when you "clear" it, it should be clear... not covered in blocks.
> I'm guessing you're using a character display rather than a graphics
> display? Anyway, if the contrast is set incorrectly, what you're
> describing is what you'd see. Power on the display (without
> intialising it), and adjust the contrast until the character blocks
> are a light grey colour. Once you've got text/data you can see, you
> can tweak it from there. Too low or too high and you won't see squat.
> Good luck
>
> --- In l..., "oldulik" wrote:
>>
>> Hello to all, I hope, somebody here will help me. I have a problem
>> with initializing LCD displej connecting to LPC2138. I have a display
>> from Everboucket, MC16021E8 SYL.
>> After connecting 5V, only black squares, after uploading the
>> initialization sequence, its same. I think, that there isnt HW
>> problem, but its SW, but I dont know, where Im doing mistake. Here is
>> my initialization sequence. Thank to all idea.
>> Oldriska
>>
>> #include
>>
>> void InitDisplay(void);
>> void LCDSendCommand(unsigned long a);
>> unsigned long data;
>>
>> void DelayS (unsigned long a)
>> { while (--a!=0); } //jednotka je 1us
>>
>> void Enable(void)
>> {
>> IOSET0 = 0x00100000; //P0.20 - EN do 1
>> DelayS(10);
>> IOCLR0 = 0x00100000; //P0.20 - EN do 0
>> }
>>
>> unsigned long data;
>>
>> void main(void)
>> {
>> InitDisplay();
>>
>> }
>>
>> void InitDisplay(void)
>> {
>> IODIR0 = 0x0030F000;
>> IOCLR0 = 0x0030F000;
>>
>> DelayS(15000); //cekani 15ms na vnitrni reset
>>
>> IOSET0 = 0x00003000; //8bit interface
>> Enable();
>> DelayS(4100); //min 4.1ms
>>
>> IOSET0 = 0x00003000; //8bit interface
>> Enable();
>> DelayS(100); //100us
>>
>> IOSET0 = 0x00003000; //8bit interface
>> Enable();
>> DelayS(40); //40us
>>
>> IOSET0 = 0x00002000; //4bit inteface
>> Enable();
>> DelayS(40); //40us
>> LCDSendCommand(0x00002800); // 4bitovy mod, 2 radky, 5x7 puntiku
>> //function set
>> DelayS(40);
>>
>> LCDSendCommand(0x00000800); //display off
>> DelayS(40);
>>
>> LCDSendCommand(0x00000100); // clear display
>> DelayS(1600);
>>
>> LCDSendCommand(0x00000600); // entry mode set
>> DelayS(40);
>>
>> }
>>
>> void LCDSendCommand(unsigned long a)
>> {
>> IOCLR0= 0x01000000; //24,set RW port to 0
>>
>> DelayS(2000); //delay for LCD char ~2ms
>>
>> data = 0xffff0fff | a; //get high 4 bits
>> IOCLR0 = 0x0000f000; //clear D4-D7
>> IOSET0 = (IOSET0 | 0x0000f000) & data; //set D4-D7
>> IOCLR0= 0x00200000; //23,set RS port to 0 ->
>> display set to comand mode
>> Enable(); //pulse to set d4-d7 bits
>> data = (a << 4) & 0x0000f000; //get low 4 bits
>> IOCLR0= 0x0000f000; //clear D4-D7
>> IOSET0 = (IOSET0 & 0xffff0fff) | data; //set D4-D7 (only
>> PORTC4-PORTC7)
>> IOCLR0= 0x00200000; //set RS port to 0 -> display
>> set to command mode
>> Enable(); //pulse to set d4-d7 bits
>>
>> }
>> Yahoo! Groups Links
If you are getting blocks on the LCD, then check your contrast. You may
well be displaying data but can't see it due to the contrast being set
too high.
oldulik wrote:
>
> Hello to all, I hope, somebody here will help me. I have a problem
> with initializing LCD displej connecting to LPC2138. I have a display
> from Everboucket, MC16021E8 -- SYL.
> After connecting 5V, only black squares, after uploading the
> initialization sequence, its same. I think, that there isnt HW
> problem, but its SW, but I dont know, where Im doing mistake. Here is
> my initialization sequence. Thank to all idea.
> Oldriska
>
> #include void InitDisplay(void);
> void LCDSendCommand(unsigned long a);
> unsigned long data;
>
> void DelayS (unsigned long a)
> { while (--a!=0); } //jednotka je 1us
>
> void Enable(void)
> {
> IOSET0 = 0x00100000; //P0.20 - EN do 1
> DelayS(10);
> IOCLR0 = 0x00100000; //P0.20 - EN do 0
> }
>
> unsigned long data;
>
> void main(void)
> {
> InitDisplay();
>
> }
>
> void InitDisplay(void)
> {
> IODIR0 = 0x0030F000;
> IOCLR0 = 0x0030F000;
>
> DelayS(15000); //cekani 15ms na vnitrni reset
>
> IOSET0 = 0x00003000; //8bit interface
> Enable();
> DelayS(4100); //min 4.1ms
>
> IOSET0 = 0x00003000; //8bit interface
> Enable();
> DelayS(100); //100us
>
> IOSET0 = 0x00003000; //8bit interface
> Enable();
> DelayS(40); //40us
>
> IOSET0 = 0x00002000; //4bit inteface
> Enable();
> DelayS(40); //40us
>
> LCDSendCommand(0x00002800); // 4bitovy mod, 2 radky, 5x7 puntiku
> //function set
> DelayS(40);
>
> LCDSendCommand(0x00000800); //display off
> DelayS(40);
>
> LCDSendCommand(0x00000100); // clear display
> DelayS(1600);
>
> LCDSendCommand(0x00000600); // entry mode set
> DelayS(40);
>
> }
>
> void LCDSendCommand(unsigned long a)
> {
> IOCLR0= 0x01000000; //24,set RW port to 0
>
> DelayS(2000); //delay for LCD char ~2ms
>
> data = 0xffff0fff | a; //get high 4 bits
> IOCLR0 = 0x0000f000; //clear D4-D7
> IOSET0 = (IOSET0 | 0x0000f000) & data; //set D4-D7
> IOCLR0= 0x00200000; //23,set RS port to 0 ->
> display set to comand mode
> Enable(); //pulse to set d4-d7 bits
>
> data = (a << 4) & 0x0000f000; //get low 4 bits
> IOCLR0= 0x0000f000; //clear D4-D7
> IOSET0 = (IOSET0 & 0xffff0fff) | data; //set D4-D7 (only
> PORTC4-PORTC7)
> IOCLR0= 0x00200000; //set RS port to 0 -> display
> set to command mode
> Enable(); //pulse to set d4-d7 bits
>
> }
>
>
I think, that contrast will be fine, I havent initialized display, the
black squares are visible after connecting the power, then I want to
initialize display, so I think, that after initializing must the
squares go out. I have to send any data not yet, I only send
initialization sequence.

--- In l..., Darcy Williams wrote:
>
> If you are getting blocks on the LCD, then check your contrast. You
may
> well be displaying data but can't see it due to the contrast being set
> too high.
> oldulik wrote:
> >
> > Hello to all, I hope, somebody here will help me. I have a problem
> > with initializing LCD displej connecting to LPC2138. I have a display
> > from Everboucket, MC16021E8 -- SYL.
> > After connecting 5V, only black squares, after uploading the
> > initialization sequence, its same. I think, that there isnt HW
> > problem, but its SW, but I dont know, where Im doing mistake. Here is
> > my initialization sequence. Thank to all idea.
> > Oldriska
> >
> > #include
> >
> > void InitDisplay(void);
> > void LCDSendCommand(unsigned long a);
> > unsigned long data;
> >
> > void DelayS (unsigned long a)
> > { while (--a!=0); } //jednotka je 1us
> >
> > void Enable(void)
> > {
> > IOSET0 = 0x00100000; //P0.20 - EN do 1
> > DelayS(10);
> > IOCLR0 = 0x00100000; //P0.20 - EN do 0
> > }
> >
> > unsigned long data;
> >
> > void main(void)
> > {
> > InitDisplay();
> >
> > }
> >
> > void InitDisplay(void)
> > {
> > IODIR0 = 0x0030F000;
> > IOCLR0 = 0x0030F000;
> >
> > DelayS(15000); //cekani 15ms na vnitrni reset
> >
> > IOSET0 = 0x00003000; //8bit interface
> > Enable();
> > DelayS(4100); //min 4.1ms
> >
> > IOSET0 = 0x00003000; //8bit interface
> > Enable();
> > DelayS(100); //100us
> >
> > IOSET0 = 0x00003000; //8bit interface
> > Enable();
> > DelayS(40); //40us
> >
> > IOSET0 = 0x00002000; //4bit inteface
> > Enable();
> > DelayS(40); //40us
> >
> > LCDSendCommand(0x00002800); // 4bitovy mod, 2 radky, 5x7 puntiku
> > //function set
> > DelayS(40);
> >
> > LCDSendCommand(0x00000800); //display off
> > DelayS(40);
> >
> > LCDSendCommand(0x00000100); // clear display
> > DelayS(1600);
> >
> > LCDSendCommand(0x00000600); // entry mode set
> > DelayS(40);
> >
> > }
> >
> > void LCDSendCommand(unsigned long a)
> > {
> > IOCLR0= 0x01000000; //24,set RW port to 0
> >
> > DelayS(2000); //delay for LCD char ~2ms
> >
> > data = 0xffff0fff | a; //get high 4 bits
> > IOCLR0 = 0x0000f000; //clear D4-D7
> > IOSET0 = (IOSET0 | 0x0000f000) & data; //set D4-D7
> > IOCLR0= 0x00200000; //23,set RS port to 0 ->
> > display set to comand mode
> > Enable(); //pulse to set d4-d7 bits
> >
> > data = (a << 4) & 0x0000f000; //get low 4 bits
> > IOCLR0= 0x0000f000; //clear D4-D7
> > IOSET0 = (IOSET0 & 0xffff0fff) | data; //set D4-D7 (only
> > PORTC4-PORTC7)
> > IOCLR0= 0x00200000; //set RS port to 0 -> display
> > set to command mode
> > Enable(); //pulse to set d4-d7 bits
> >
> > }
> >
> >
>
>
Both ideas are correct. Here's how:

1> Contrast issue - All lines and All blocks will be filled solid.
2> Uninitialized LCD - Only some rows of blocks are solid (e.g. only top
row of a 2 row LCD)

Re-reading the original post, it is not clear which is the case.

--Johnny

oldulik wrote:
> I think, that contrast will be fine, I havent initialized display, the
> black squares are visible after connecting the power, then I want to
> initialize display, so I think, that after initializing must the
> squares go out. I have to send any data not yet, I only send
> initialization sequence.
>
> --- In l..., Darcy Williams wrote:
>> If you are getting blocks on the LCD, then check your contrast. You
> may
>> well be displaying data but can't see it due to the contrast being set
>> too high.
>> oldulik wrote:
>>> Hello to all, I hope, somebody here will help me. I have a problem
>>> with initializing LCD displej connecting to LPC2138. I have a display
>>> from Everboucket, MC16021E8 -- SYL.
>>> After connecting 5V, only black squares, after uploading the
>>> initialization sequence, its same. I think, that there isnt HW
>>> problem, but its SW, but I dont know, where Im doing mistake. Here is
>>> my initialization sequence. Thank to all idea.
>>> Oldriska
>>>
>>> #include
>>>
>>> void InitDisplay(void);
>>> void LCDSendCommand(unsigned long a);
>>> unsigned long data;
>>>
>>> void DelayS (unsigned long a)
>>> { while (--a!=0); } //jednotka je 1us
>>>
>>> void Enable(void)
>>> {
>>> IOSET0 = 0x00100000; //P0.20 - EN do 1
>>> DelayS(10);
>>> IOCLR0 = 0x00100000; //P0.20 - EN do 0
>>> }
>>>
>>> unsigned long data;
>>>
>>> void main(void)
>>> {
>>> InitDisplay();
>>>
>>> }
>>>
>>> void InitDisplay(void)
>>> {
>>> IODIR0 = 0x0030F000;
>>> IOCLR0 = 0x0030F000;
>>>
>>> DelayS(15000); //cekani 15ms na vnitrni reset
>>>
>>> IOSET0 = 0x00003000; //8bit interface
>>> Enable();
>>> DelayS(4100); //min 4.1ms
>>>
>>> IOSET0 = 0x00003000; //8bit interface
>>> Enable();
>>> DelayS(100); //100us
>>>
>>> IOSET0 = 0x00003000; //8bit interface
>>> Enable();
>>> DelayS(40); //40us
>>>
>>> IOSET0 = 0x00002000; //4bit inteface
>>> Enable();
>>> DelayS(40); //40us
>>>
>>> LCDSendCommand(0x00002800); // 4bitovy mod, 2 radky, 5x7 puntiku
>>> //function set
>>> DelayS(40);
>>>
>>> LCDSendCommand(0x00000800); //display off
>>> DelayS(40);
>>>
>>> LCDSendCommand(0x00000100); // clear display
>>> DelayS(1600);
>>>
>>> LCDSendCommand(0x00000600); // entry mode set
>>> DelayS(40);
>>>
>>> }
>>>
>>> void LCDSendCommand(unsigned long a)
>>> {
>>> IOCLR0= 0x01000000; //24,set RW port to 0
>>>
>>> DelayS(2000); //delay for LCD char ~2ms
>>>
>>> data = 0xffff0fff | a; //get high 4 bits
>>> IOCLR0 = 0x0000f000; //clear D4-D7
>>> IOSET0 = (IOSET0 | 0x0000f000) & data; //set D4-D7
>>> IOCLR0= 0x00200000; //23,set RS port to 0 ->
>>> display set to comand mode
>>> Enable(); //pulse to set d4-d7 bits
>>>
>>> data = (a << 4) & 0x0000f000; //get low 4 bits
>>> IOCLR0= 0x0000f000; //clear D4-D7
>>> IOSET0 = (IOSET0 & 0xffff0fff) | data; //set D4-D7 (only
>>> PORTC4-PORTC7)
>>> IOCLR0= 0x00200000; //set RS port to 0 -> display
>>> set to command mode
>>> Enable(); //pulse to set d4-d7 bits
>>>
>>> }
>>>
>>>
>>
>>
>
Yes, the second idea is my case, Only the first row is filled solid.
So its unitialized display. I have debug the program and all signals
fits, so I think that problem is in timing.
I'm using this timing sequence:

void Delay (unsigned long a)
{ while (--a>0); }

I hope when I wrote for example Delay(10); it's 10 us, but now I'm not
sure if it's so. Because when I simulate it, the times were shorter.
So I need some time delay loop, where it will be sure what delay time
I'm writing.
Oldriska

--- In l..., Johnny Cybermyth wrote:
>
> Both ideas are correct. Here's how:
>
> 1> Contrast issue - All lines and All blocks will be filled solid.
> 2> Uninitialized LCD - Only some rows of blocks are solid (e.g. only
top
> row of a 2 row LCD)
>
> Re-reading the original post, it is not clear which is the case.
>
> --Johnny
>
> oldulik wrote:
> > I think, that contrast will be fine, I havent initialized display, the
> > black squares are visible after connecting the power, then I want to
> > initialize display, so I think, that after initializing must the
> > squares go out. I have to send any data not yet, I only send
> > initialization sequence.
> >
> > --- In l..., Darcy Williams wrote:
> >> If you are getting blocks on the LCD, then check your contrast. You
> > may
> >> well be displaying data but can't see it due to the contrast
being set
> >> too high.
> >>
> >>
> >> oldulik wrote:
> >>> Hello to all, I hope, somebody here will help me. I have a problem
> >>> with initializing LCD displej connecting to LPC2138. I have a
display
> >>> from Everboucket, MC16021E8 -- SYL.
> >>> After connecting 5V, only black squares, after uploading the
> >>> initialization sequence, its same. I think, that there isnt HW
> >>> problem, but its SW, but I dont know, where Im doing mistake.
Here is
> >>> my initialization sequence. Thank to all idea.
> >>> Oldriska
> >>>
> >>> #include
> >>>
> >>> void InitDisplay(void);
> >>> void LCDSendCommand(unsigned long a);
> >>> unsigned long data;
> >>>
> >>> void DelayS (unsigned long a)
> >>> { while (--a!=0); } //jednotka je 1us
> >>>
> >>> void Enable(void)
> >>> {
> >>> IOSET0 = 0x00100000; //P0.20 - EN do 1
> >>> DelayS(10);
> >>> IOCLR0 = 0x00100000; //P0.20 - EN do 0
> >>> }
> >>>
> >>> unsigned long data;
> >>>
> >>> void main(void)
> >>> {
> >>> InitDisplay();
> >>>
> >>> }
> >>>
> >>> void InitDisplay(void)
> >>> {
> >>> IODIR0 = 0x0030F000;
> >>> IOCLR0 = 0x0030F000;
> >>>
> >>> DelayS(15000); //cekani 15ms na vnitrni reset
> >>>
> >>> IOSET0 = 0x00003000; //8bit interface
> >>> Enable();
> >>> DelayS(4100); //min 4.1ms
> >>>
> >>> IOSET0 = 0x00003000; //8bit interface
> >>> Enable();
> >>> DelayS(100); //100us
> >>>
> >>> IOSET0 = 0x00003000; //8bit interface
> >>> Enable();
> >>> DelayS(40); //40us
> >>>
> >>> IOSET0 = 0x00002000; //4bit inteface
> >>> Enable();
> >>> DelayS(40); //40us
> >>>
> >>> LCDSendCommand(0x00002800); // 4bitovy mod, 2 radky, 5x7 puntiku
> >>> //function set
> >>> DelayS(40);
> >>>
> >>> LCDSendCommand(0x00000800); //display off
> >>> DelayS(40);
> >>>
> >>> LCDSendCommand(0x00000100); // clear display
> >>> DelayS(1600);
> >>>
> >>> LCDSendCommand(0x00000600); // entry mode set
> >>> DelayS(40);
> >>>
> >>> }
> >>>
> >>> void LCDSendCommand(unsigned long a)
> >>> {
> >>> IOCLR0= 0x01000000; //24,set RW port to 0
> >>>
> >>> DelayS(2000); //delay for LCD char ~2ms
> >>>
> >>> data = 0xffff0fff | a; //get high 4 bits
> >>> IOCLR0 = 0x0000f000; //clear D4-D7
> >>> IOSET0 = (IOSET0 | 0x0000f000) & data; //set D4-D7
> >>> IOCLR0= 0x00200000; //23,set RS port to 0 ->
> >>> display set to comand mode
> >>> Enable(); //pulse to set d4-d7 bits
> >>>
> >>> data = (a << 4) & 0x0000f000; //get low 4 bits
> >>> IOCLR0= 0x0000f000; //clear D4-D7
> >>> IOSET0 = (IOSET0 & 0xffff0fff) | data; //set D4-D7 (only
> >>> PORTC4-PORTC7)
> >>> IOCLR0= 0x00200000; //set RS port to 0 -> display
> >>> set to command mode
> >>> Enable(); //pulse to set d4-d7 bits
> >>>
> >>> }
> >>>
> >>>
> >>
> >>
> >>
> >
> >
>
oldulik Wrote
>Yes, the second idea is my case, Only the first row is filled solid.
>So its unitialized display. I have debug the program and all signals
>fits, so I think that problem is in timing.
>I'm using this timing sequence:
>
>void Delay (unsigned long a)
>{ while (--a>0); }
>
>I hope when I wrote for example Delay(10); it's 10 us, but now I'm not

Why would you think that?

I did some measurements (including overhead) for a more complicated timer
based on the HW timers on the LPC.

http://www.aeolusdevelopment.com/AppNotes/LPC210X/an-timerperformance.pdf

If you are going to use a simple delay loop as you wrote you are going to
have to dig out the scope and measure the response time. Simpler to use
the timers and easier to change when you change clock frequencies.

Robert
--------------------------------
myhosting.com - Premium Microsoft Windows and Linux web and application
hosting - http://link.myhosting.com/myhosting
--- In l..., "oldulik" wrote:
>
> Hello to all, I hope, somebody here will help me. I have a problem
> with initializing LCD displej connecting to LPC2138. I have a display
> from Everboucket, MC16021E8 SYL.
> After connecting 5V, only black squares, after uploading the
> initialization sequence, its same.

Do you have a source for contrast voltage connected? One way for a
display to have all black bars is to have the contrast turned all the
way up. The contrast input is usually pin 3 and just needs a 20K pot
from +5 Volts to ground, with the wiper tied to pin 3. Check the
datasheet for the module you are using.

--TimR