I am obviously missing something fundamental with regard to writing data to this display. I suspect it is related to the character generator and / or display memory and how to set these up or use them properly.
I have been able to get the top half and bottom half of the display intitialized and it looks like it ought to be working.
I have DEBUG status messages in my code and I can confirm that I am writing what I think I am writing out to the display.
I am doing something wrong in writing data as there is no data being displayed and the cursor does not move to indicate that a write has happened.
I have included my code.
Thanks for your help
Tim Vukman
Code: Select all
// LCD Routines for MOP-AL404C
// October 2008
// Tim Vukman
//****************************************************************************************
// LCD Pin Definitions
//****************************************************************************************
int RS = 12; // Arduino Digital 12
// DB0 - DB3 tied to GROUND
// DB4 - DB8 // Arduino Digital 8 to Digital 11
// // Conveniently maps to PortB 0 - PortB 4
int CE1 = 7; // Enable 1 line
int CE2 = 6; // Enable 2 line
//****************************************************************************************
// LCD Send Command
//****************************************************************************************
// cmd will receive the command value in hex
// delay1 will receive the first delay value
// delay2 will receive the second delay value
// bank will receive either Enable 1 or Enable 2 depending on what is being updated
//****************************************************************************************
void LcdCommandWrite(char cmd, unsigned int delay1, unsigned int delay2, char bank)
{
digitalWrite(RS, LOW); // Set RS to 0 for command
digitalWrite(bank,HIGH); // Raise the enable line
PORTB = ((cmd & 0xF0) >>4); // Write the high nibble to PORTB
Serial.print("LCD Command Upper Nibble :"); // DEBUG - description label
Serial.println(PORTB, HEX); // DEBUG - value to display in IDE
digitalWrite(bank, LOW); // Lower the enable line
digitalWrite(RS, HIGH); // Set RS to 1 for data
delay(delay1); // Delay
digitalWrite(RS, LOW); // Set RS to 0 for command
digitalWrite(bank, HIGH); // Raise the enable line
PORTB = ((cmd & 0x0F)); // Write the low nibble to PORTB
Serial.print("LCD Command Lower Nibble :"); // DEBUG - description label
Serial.println(PORTB, HEX); // DEBUG - value to display in IDE
digitalWrite(bank, LOW); // Lower the enable line
digitalWrite(RS, HIGH); // Set RS to 1 for data
delay(delay2); // Delay
}
//****************************************************************************************
// LCD Send Data
//****************************************************************************************
// data will receive the data value in hex
// delay1 will receive the first delay value
// delay2 will receive the second delay value
// bank will receive either Enable 1 or Enable 2 depending on what is being updated
//****************************************************************************************
void LcdDataWrite(char data, unsigned int delay1, unsigned int delay2, char bank)
{
digitalWrite(RS, HIGH); // Set RS to 1 for data
digitalWrite(bank,HIGH); // Raise the enable line
PORTB = ((data & 0xF0) >>4); // Write the high nibble to PORTB
Serial.print("LCD Data Upper Nibble :"); // DEBUG - description label
Serial.println(PORTB, HEX); // DEBUG - value to display in IDE
digitalWrite(bank, LOW); // Lower the enable line
digitalWrite(RS, LOW); // Set RS to 0 for command
delay(delay1); // Delay
digitalWrite(RS, HIGH); // Set RS to 1 for data
digitalWrite(bank, HIGH); // Raise the enable line
PORTB = ((data & 0x0F)); // Write the high nibble to PORTB
Serial.print("LCD Data Lower Nibble :"); // DEBUG - description label
Serial.println(PORTB, HEX); // DEBUG - value to display in IDE
digitalWrite(bank, LOW); // Lower the enable line
digitalWrite(RS, LOW); // Set RS to 0 for command
delay(delay2); // Delay
}
//****************************************************************************************
// LCD Initialization
//****************************************************************************************
void setup(void)
{
pinMode(CE1, OUTPUT); // Set Arduino Digital 7 as OUTPUT E1
pinMode(CE2, OUTPUT); // Set Arduino Digital 6 as OUTPUT E2
DDRB = DDRB | B00011111; // Set Arduion Digital 8 - 11 to OUTPUT
delay(50); // Delay
Serial.begin(9600); // DEBUG - Start IDE communication
Serial.println("Init Top Half"); // DEBUG - Status Message
delay(100); // Delay
Serial.println("1st Function Set "); // DEBUG - Status Message
LcdCommandWrite(0x33, 10, 10, CE1); // Wake up LCD top
delay(10); // Delay
Serial.println("2nd Function Set "); // DEBUG - Status Message
LcdCommandWrite(0x32, 10, 10, CE1); // Set LCD to 2 Line
delay(10); // Delay
Serial.println("3rd Function Set "); // DEBUG - Status Message
LcdCommandWrite(0x2C, 10, 10, CE1); // Set LCD to 4 bit with Cursor
delay(5); // Delay
Serial.println("Display on / off "); // DEBUG - Status Message
LcdCommandWrite(0x0E, 5, 5, CE1); // Set Set cursor not blinking and display on
delay(5); // Delay
Serial.println("Set Entry Mode "); // DEBUG - Status Message
LcdCommandWrite(0x01, 5, 5, CE1); // Set cursor to home
delay(5); // Delay
// Set up Bottom Half of LCD
Serial.println("Init Bottom Half"); // DEBUG - Status Message
delay(100); // Delay
Serial.println("1st Function Set "); // DEBUG - Status Message
LcdCommandWrite(0x33, 10, 10, CE2); // Wake up LCD bottom
delay(10); // Delay
Serial.println("2nd Function Set "); // DEBUG - Status Message
LcdCommandWrite(0x32, 10, 10, CE2); // Set LCD to 2 Line
delay(10); // Delay
Serial.println("3rd Function Set "); // DEBUG - Status Message
LcdCommandWrite(0x2C, 10, 10, CE2); // Set LCD to 4 bit with Cursor // function set:
delay(5); // Delay
Serial.println("Display on / off "); // DEBUG - Status Message
LcdCommandWrite(0x0E, 5, 5, CE2); // Set cursor not blinking and display on
delay(5); // Delay
Serial.println("Set Entry Mode "); // DEBUG - Status Message
LcdCommandWrite(0x01, 5, 5, CE2); // Set cursor to home
delay(5); // Delay
//
}
void loop (void)
{
Serial.print("Loop ");
LcdCommandWrite(0x02, 10, 10, CE1); // set cursor position to zero top 2 lines
LcdCommandWrite(0x02, 10, 10, CE2); // set cursor position to zero bottom 2 lines
// Write the welcome message
LcdDataWrite(0x48, 5, 5, CE1); // no character cursor flashing at home position
LcdDataWrite('e', 5, 5, CE1); // another always on cursor at Line 2 Column 9
LcdDataWrite(0x6C, 5, 5, CE1);
LcdDataWrite('l', 5, 5, CE1);
LcdDataWrite(0x6F, 5, 5, CE1);
delay(500);
// Write the welcome message
LcdDataWrite(0x48, 5, 5, CE2); // no character cursor flashing at home position
LcdDataWrite('e', 5, 5, CE2); // another always on cursor at Line 2 Column 9
LcdDataWrite(0x6C, 5, 5, CE2);
LcdDataWrite('l', 5, 5, CE2);
LcdDataWrite(0x6F, 5, 5, CE2);
}