MOP-AL404C Initialization problems
Posted: Mon Jun 11, 2007 1:39 am
Hi,
I recently ordered 2 of the MOP-AL404 LCDs. I have been trying for a few days now to get them to work but I can't seem to initialize them. All I get is the 1st and 3rd row of black bars. I've checked the forums but there doesn't seem to be very much information on this display.
I am trying to initialize for 4bit 4line mode. I understand that the first two lines are controlled by one Chip (E1) and the second by another Chip (E2).... so right now I am trying to set the first chip into 2line mode and right "Hello World".
I am using an Atmel Atmega128. I checked the connections according to the following datasheet (http://www.matrixorbital.ca/manuals/mop ... 404C-E.pdf)
LCD1-4(DB0-DB3): Gnd
LCD5-8(DB4-DB7): PortC 0-3
LCD9(E1): PortC 6
LCD10(R/W): PortC 5
LCD11(RS): PortC 4
LCD12(Vo): 10k Pot (Middle Tab)
LCD13(Gnd): Gnd
LCD14(Vcc): 5+
LCD15(E2): Gnd (For now)
LCD16(NC): NC
Here is the Atmel Code in C:
//=================================================================================================
//Description:
//Precondition:
//Postcondition:
//Returns:
void init_LCD()
{
DDRC |= 0x7F; //PORTC(6) is Enable
//PORTC 5-0 = R/W | RS | DB7 | DB6 | DB5 | DB4
timer_bdelay(45); //Delay for 15ms to allow VCC to settle
lcd_writeCmd(0x33, 10, 10); //Manual Initialization of LCD Driver
lcd_writeCmd(0x32, 10, 10); //Four bit operation
lcd_writeCmd(0x28, 5, 5); //Enable 2 lines
lcd_writeCmd(0x0F, 5, 5); //Display on; Cursor On; Blink On
lcd_writeCmd(0x01, 5, 5); //Clear Screen; Cursor Home
}
//=================================================================================================
//=================================================================================================
//Description: Abstracts how commands are written to the LCD driver
//Precondition: The lcd has been init and is in 4 bit mode
//Postcondition: The command has been executed
//Returns:
void lcd_writeCmd(char cmd, unsigned int wdelay, unsigned int edelay)
{
PORTC = ( (cmd & 0xF0) >> 4) | 0x40; //Write upper nibble to cmd register
PORTC ^= 0x40; // Enable = 0... Falling edge signals to read bus
timer_bdelay(wdelay); //Delay 1ms for write to settle [Hold time > 100us]
PORTC = ( (cmd & 0x0F) ) | 0x40; //Write lower nibble to cmd register
PORTC ^= 0x40;
timer_bdelay(edelay); //Delay 2ms (Wait for instruction to execute)
}
//=================================================================================================
//=================================================================================================
//Description: Abstracts how data is written to the LCD
//Precondition: the lcd has been init and is in 4 bit mode
//Postcondition: The character appears on the screen at the current cursor posistion
//Returns:
void lcd_writeData(char data, unsigned int wdelay, unsigned int edelay)
{
PORTC = ( (data & 0xF0) >> 4) | 0x40 | 0x10; //Enable = 1... RS = Data register
PORTC ^= 0x40; // Enable = 0... Falling edge signals to read bus
timer_bdelay(wdelay); //Delay 1ms for write to settle [Hold time > 100us]
PORTC = ( (data & 0x0F) ) | 0x40 | 0x10; //Write lower nibble to cmd register
PORTC ^= 0x40;
timer_bdelay(edelay); //Delay 2ms (Wait for instruction to execute)
}
//=================================================================================================
I have two other LCDs 20x2 and they work perfectly with this code. They have the HD44780u Chip which the site claims the MOPs are compatiable with.
Thanks,
Thomas McDonley
I recently ordered 2 of the MOP-AL404 LCDs. I have been trying for a few days now to get them to work but I can't seem to initialize them. All I get is the 1st and 3rd row of black bars. I've checked the forums but there doesn't seem to be very much information on this display.
I am trying to initialize for 4bit 4line mode. I understand that the first two lines are controlled by one Chip (E1) and the second by another Chip (E2).... so right now I am trying to set the first chip into 2line mode and right "Hello World".
I am using an Atmel Atmega128. I checked the connections according to the following datasheet (http://www.matrixorbital.ca/manuals/mop ... 404C-E.pdf)
LCD1-4(DB0-DB3): Gnd
LCD5-8(DB4-DB7): PortC 0-3
LCD9(E1): PortC 6
LCD10(R/W): PortC 5
LCD11(RS): PortC 4
LCD12(Vo): 10k Pot (Middle Tab)
LCD13(Gnd): Gnd
LCD14(Vcc): 5+
LCD15(E2): Gnd (For now)
LCD16(NC): NC
Here is the Atmel Code in C:
//=================================================================================================
//Description:
//Precondition:
//Postcondition:
//Returns:
void init_LCD()
{
DDRC |= 0x7F; //PORTC(6) is Enable
//PORTC 5-0 = R/W | RS | DB7 | DB6 | DB5 | DB4
timer_bdelay(45); //Delay for 15ms to allow VCC to settle
lcd_writeCmd(0x33, 10, 10); //Manual Initialization of LCD Driver
lcd_writeCmd(0x32, 10, 10); //Four bit operation
lcd_writeCmd(0x28, 5, 5); //Enable 2 lines
lcd_writeCmd(0x0F, 5, 5); //Display on; Cursor On; Blink On
lcd_writeCmd(0x01, 5, 5); //Clear Screen; Cursor Home
}
//=================================================================================================
//=================================================================================================
//Description: Abstracts how commands are written to the LCD driver
//Precondition: The lcd has been init and is in 4 bit mode
//Postcondition: The command has been executed
//Returns:
void lcd_writeCmd(char cmd, unsigned int wdelay, unsigned int edelay)
{
PORTC = ( (cmd & 0xF0) >> 4) | 0x40; //Write upper nibble to cmd register
PORTC ^= 0x40; // Enable = 0... Falling edge signals to read bus
timer_bdelay(wdelay); //Delay 1ms for write to settle [Hold time > 100us]
PORTC = ( (cmd & 0x0F) ) | 0x40; //Write lower nibble to cmd register
PORTC ^= 0x40;
timer_bdelay(edelay); //Delay 2ms (Wait for instruction to execute)
}
//=================================================================================================
//=================================================================================================
//Description: Abstracts how data is written to the LCD
//Precondition: the lcd has been init and is in 4 bit mode
//Postcondition: The character appears on the screen at the current cursor posistion
//Returns:
void lcd_writeData(char data, unsigned int wdelay, unsigned int edelay)
{
PORTC = ( (data & 0xF0) >> 4) | 0x40 | 0x10; //Enable = 1... RS = Data register
PORTC ^= 0x40; // Enable = 0... Falling edge signals to read bus
timer_bdelay(wdelay); //Delay 1ms for write to settle [Hold time > 100us]
PORTC = ( (data & 0x0F) ) | 0x40 | 0x10; //Write lower nibble to cmd register
PORTC ^= 0x40;
timer_bdelay(edelay); //Delay 2ms (Wait for instruction to execute)
}
//=================================================================================================
I have two other LCDs 20x2 and they work perfectly with this code. They have the HD44780u Chip which the site claims the MOPs are compatiable with.
Thanks,
Thomas McDonley