Problem initializing AL-162
Moderator: Mods
-
- LCD?
- Posts: 5
- Joined: Mon Jun 25, 2007 8:20 am
Problem initializing AL-162
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);
}
}
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);
}
}
-
- LCD?
- Posts: 5
- Joined: Mon Jun 25, 2007 8:20 am
r/w
the r/w is connected to the ground, because I only need writing and no reading back
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 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
Design and Development
Matrix Orbital
-
- LCD?
- Posts: 5
- Joined: Mon Jun 25, 2007 8:20 am
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);
}
}
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);
}
}
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.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,
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.
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.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).
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.
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.
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
Design and Development
Matrix Orbital
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.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.
-
- LCD?
- Posts: 5
- Joined: Mon Jun 25, 2007 8:20 am
-
- LCD?
- Posts: 5
- Joined: Mon Jun 25, 2007 8:20 am