Problem initializing AL-162

Support for MOC/MOS/MOI/MOU/X-Board/MOP

Moderator: Mods

silverstein
LCD?
Posts: 5
Joined: Mon Jun 25, 2007 8:20 am

Problem initializing AL-162

Post by silverstein »

Im having problem initializing my AL-162A, does anyone has any idea what I am doing wrong?

PORTA : 0 - 7 (DB0 - DB7)
PORTC : 0 = register select 1 = Enable

the source is written for an ATmega uC

void init_devices(void)
{
cli();
DDRA = 0xFF;
DDRC = 0xFF;
PORTA = 0x00;
PORTC = 0x00;
sei();
}


void init_lcd(void)
{

_delay_ms(100);

PORTC &= !0x03; // reset E and RS

int iaInit[6];
iaInit[0] = 0x38; // function set: 8-bit, 2-line, 5*7 dots
iaInit[1] = 0x38; // function set: 8-bit, 2-line, 5*7 dots
iaInit[3] = 0x0C; // display control: display on, cursor off
iaInit[3] = 0x01; // clear display
iaInit[4] = 0x04; // entry mode: curser decrement, shift invisible

int count;
for(count = 0; count <=4; count ++)
{
PORTA = iaInit[count];
PORTC = PORTC | 0x02; // set Enable
_delay_ms(100);
PORTC &= !0x02; // reset Enable
_delay_ms(100);
}
}

Raquel
Matrix Orbital
Matrix Orbital
Posts: 803
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel »

Hello silverstein,

Thanks for your post.

Do you have the R/W line connected?

Best Regards,
Raquel Malinis
Design and Development
Matrix Orbital

silverstein
LCD?
Posts: 5
Joined: Mon Jun 25, 2007 8:20 am

r/w

Post by silverstein »

the r/w is connected to the ground, because I only need writing and no reading back

Raquel
Matrix Orbital
Matrix Orbital
Posts: 803
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel »

Hello silverstein,

I am looking at page 45 of this data sheet for the HD44780U.
I do not think that the code you have posted comply to it. Can you please check if ou can follow the suggested initialization?

Thanks,
Raquel Malinis
Design and Development
Matrix Orbital

silverstein
LCD?
Posts: 5
Joined: Mon Jun 25, 2007 8:20 am

Post by silverstein »

this is my current complete source,
if i use that initialization it still wont work


//////////////////////////////////
// main //
//////////////////////////////////

main()
{
init_devices();
init_lcd();
sendtest();
while(1)
{
}

}

//////////////////////////////////
// initialisations //
//////////////////////////////////

void init_devices(void)
{
cli();
DDRA = 0xFF;
DDRC = 0xFF;
PORTA = 0x00;
PORTC = 0x00;
MCUCR = 0x00;
sei();
}


void init_lcd(void)
{

_delay_ms(100);

PORTC &= !0x03; // reset E and RS

int iaInit[8];
iaInit[0] = 0x30;
iaInit[1] = 0x30;
iaInit[3] = 0x30;
iaInit[3] = 0x38;
iaInit[4] = 0x08;
iaInit[5] = 0x01;
iaInit[6] = 0x07;


/* OLD
iaInit[0] = 0x38; // function set: 8-bit, 2-line, 5*7 dots
iaInit[1] = 0x38; // function set: 8-bit, 2-line, 5*7 dots
iaInit[3] = 0x0C; // display control: display on, cursor off
iaInit[3] = 0x01; // clear display
iaInit[4] = 0x04; // entry mode: curser decrement, shift invisible
*/

int count;
for(count = 0; count <=7; count ++)
{
PORTA = iaInit[count];
PORTC = PORTC | 0x02; // set Enable
_delay_ms(100);
PORTC &= !0x02; // reset Enable
_delay_ms(100);
}
}

void sendtest(void)
{
char teststring[] = " eureka!!!! "; // de tekst

PORTC = (1<<PC0) | ( 0 << PC1); // E = 0, S = 1 (data mode)

int count;
int len = strlen(teststring);

for(count = 0; count < len; count++)
{
PORTA = teststring[count];
PORTC |= 0x02; // E = 1 (write)
_delay_ms(100);
PORTC &= !0x02; // E = 0 (finish write)
_delay_ms(100);
}
}

Raquel
Matrix Orbital
Matrix Orbital
Posts: 803
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel »

Hello,

I am not sure if !0x02 assembles the same as ~(0x02)
So instead of !0x02, can you please try ~(0x02)?

Also, you will need to have control of R/W because you will need to know if the display is ok to receive data (not busy).
Raquel Malinis
Design and Development
Matrix Orbital

Philip
LCD?
Posts: 5
Joined: Mon Jun 25, 2007 3:11 pm

Post by Philip »

Raquel wrote:Hello silverstein,

I am looking at page 45 of this data sheet for the HD44780U.
I do not think that the code you have posted comply to it. Can you please check if ou can follow the suggested initialization?

Thanks,
I'm curious....why are you linking the HD44780 manual when all of the MOP-162A list the controller type as a samsung S6A0069? I know they are very similar (possibly backwards compatible), but they all recommend a slightly different initialization sequence.

FYI, I'm also having some issues initializing this family of LCD so I'm following this thread.

Philip
Last edited by Philip on Mon Jun 25, 2007 3:30 pm, edited 1 time in total.

Philip
LCD?
Posts: 5
Joined: Mon Jun 25, 2007 3:11 pm

Post by Philip »

Raquel wrote: Also, you will need to have control of R/W because you will need to know if the display is ok to receive data (not busy).
Reading the busy flag is not a requirement, however, it is good practice. Its perfectly fine since he's using rediculously long delays. If the LCD stays busy for over 100ms then something is wrong anyway.

Philip

Philip
LCD?
Posts: 5
Joined: Mon Jun 25, 2007 3:11 pm

Post by Philip »

How fast is the instruction cycle on your ATmega? If it's running pretty fast, check to see if the setup time for data and\or RS is adequate. If not, add a little delay after setting the LCD data and RS. Your enable bit handling has sufficient delay.

Your initial initialization order (0x38, 0x38, 0x0C, 0x01, 0x04) is technically by the book (according to the AL-162A manual). The other sequence should suffice as well if the controller is indeed truely HD44780 compatible.

That's all I see. I'm running into simmilar issues.

Raquel
Matrix Orbital
Matrix Orbital
Posts: 803
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel »

By any chance, have you looked at the signals with a scope? I will try and see what I can catch with the code, but the most important thing is to follow the data sheet. I have always thought that the S6A0069 is fully compatible with the HD44780U, but you are right, Philip, they have quite a few differences.
Raquel Malinis
Design and Development
Matrix Orbital

Philip
LCD?
Posts: 5
Joined: Mon Jun 25, 2007 3:11 pm

Post by Philip »

Raquel wrote:By any chance, have you looked at the signals with a scope? I will try and see what I can catch with the code, but the most important thing is to follow the data sheet. I have always thought that the S6A0069 is fully compatible with the HD44780U, but you are right, Philip, they have quite a few differences.
As for me (i'm in a similar boat as Silver), I've verified that all pins are changing as expected and with sufficient time per the datasheet. I have a MOS model of the same LCD so tomorrow I plan to use a logic analyzer to spy on the data and control pins during it's startup. I should be able to see if the datasheet is correct and exactly why the LCD isn't initializing as expected. I'll report back what I find. I've worked with about 5 or 6 HD44780 (and compatible) based LCD's in the last few years and something is a little off with this S6A0069.

Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3002
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Post by Henry »

And this is the perfect example of why Matrix Orbital exists. ;) Talking to a raw display is a pain in the but.
Henry J.
President
Matrix Orbital

silverstein
LCD?
Posts: 5
Joined: Mon Jun 25, 2007 8:20 am

Post by silverstein »

i should use ~ instead of ! thanx for the tip :P

I use an stk500 so I use the LED's on the kit to check the codes instead of a scope.

When I use "~" instead of "!" I still don get the text on my screen :"(

silverstein
LCD?
Posts: 5
Joined: Mon Jun 25, 2007 8:20 am

Post by silverstein »

I just removed some errors of my code, and i see characters floating on my screen :) :)

If I have romoved all my bugs, i'll post the code.

Raquel
Matrix Orbital
Matrix Orbital
Posts: 803
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel »

If I have romoved all my bugs, i'll post the code.
That'll be great!

Thanks,
Raquel Malinis
Design and Development
Matrix Orbital

Post Reply