Page 1 of 2
Problem initializing AL-162
Posted: Mon Jun 25, 2007 8:40 am
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);
}
}
Posted: Mon Jun 25, 2007 10:13 am
by Raquel
Hello silverstein,
Thanks for your post.
Do you have the R/W line connected?
Best Regards,
r/w
Posted: Mon Jun 25, 2007 10:54 am
by silverstein
the r/w is connected to the ground, because I only need writing and no reading back
Posted: Mon Jun 25, 2007 11:58 am
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,
Posted: Mon Jun 25, 2007 12:45 pm
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);
}
}
Posted: Mon Jun 25, 2007 1:00 pm
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).
Posted: Mon Jun 25, 2007 3:17 pm
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
Posted: Mon Jun 25, 2007 3:20 pm
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
Posted: Mon Jun 25, 2007 3:30 pm
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.
Posted: Mon Jun 25, 2007 4:57 pm
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.
Posted: Mon Jun 25, 2007 6:59 pm
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.
Posted: Mon Jun 25, 2007 9:45 pm
by Henry
And this is the perfect example of why Matrix Orbital exists.

Talking to a raw display is a pain in the but.
Posted: Tue Jun 26, 2007 4:01 am
by silverstein
i should use ~ instead of ! thanx for the tip
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 :"(
Posted: Tue Jun 26, 2007 4:16 am
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.
Posted: Tue Jun 26, 2007 9:36 am
by Raquel
If I have romoved all my bugs, i'll post the code.
That'll be great!
Thanks,